aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/language/evaluatorscriptclass.cpp
Commit message (Collapse)AuthorAgeFilesLines
* C++: Add support for clang on WindowsChristian Kandeler2019-08-141-1/+12
| | | | | | | | | | | | | This is about clang in "mingw mode", not clang-cl. When targeting Windows, clang is a lot like mingw, so factor out the common parts into a new base module. Testing uncovered a number of invalid assumptions in our autotests, which are also fixed in this patch. In addition, minor adjustments had to be made to the Qt.core module and to the qbscore lib. Change-Id: I73085dc62a65e2a9d0397cf234c8641989246f22 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Return initializer list where it is possibleDenis Shienkov2019-02-261-6/+6
| | | | | | | | | This fixes this clang-tidy warning: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] Change-Id: I421e1e47462fe0e97788672684d47943af7df850 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Use QStringLiteral more where it is possibleDenis Shienkov2019-02-251-2/+2
| | | | | | Change-Id: I7419cc3fbc1e8776de3943852dcedab4c95d1c32 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Introduce module providersChristian Kandeler2019-01-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | If a dependency is not found, we now search for a matching module provider that can generate one for us. We also provide a generic fall-back provider which uses pkg-config to locate the dependency (but could be extended to incorporate other methods in the future). This is the most important part of this change for practical purposes, as it makes hundreds of popular libraries available for use in qbs projects without users having to write any boilerplate code. In a future patch, a module provider could also be used to implement the functionality of the qtprofilesetup library, relieving users of the need to create a profile for building Qt applications. [ChangeLog] The Depends item now falls back to pkg-config to locate dependencies whose names do not correspond to a qbs module. Fixes: QBS-1107 Change-Id: Ifd4f05c237cf58cd9fe707c3da648d3dbb33e82b Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* corelib: Apply modernize-use-autoAlessandro Portale2018-08-201-2/+2
| | | | | | | Use more auto. Change-Id: I27e1e2345c6bede459a375663be72ec3370a5e39 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Do not crash on invalid property assignment in Export itemChristian Kandeler2018-06-261-0/+12
| | | | | | | | | | | The crash would happen when creating the export information for a product whose Export item contained an assignment of the form "x.y: original", where x is not a module and the assignment was inside a Properties item. Task-number: QBS-1362 Change-Id: I900857fcd97852360ec2b75de1b7a791fd948dc4 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Catch mis-use of "original" as default property valueChristian Kandeler2018-06-181-0/+7
| | | | | | | | This used to cause an infinite recursion, eventually crashing after running out of stack space. Change-Id: I073f7163d73a70b17bab078c8a99199bc9d21eaa Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Merge 1.11 into masterChristian Kandeler2018-04-051-2/+2
|\ | | | | | | Change-Id: Ia9e19bf1317c55d84602e4e0f54f7a4f412dd600
| * SVConverter: Do not store a ValuePtr referenceJoerg Bornemann2018-03-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Storing the reference is wrong if the ValuePtr passed in the constructor is a temporary object. This is a pointer to an object that must be alive during the whole script value conversion, which is why we can just store a raw pointer. This fixes ASAN warning stack-use-after-scope. Change-Id: I8be9f226226fea32a13f8ed12cbe95ee43c8cd38 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* | Add new property type "varList"Christian Kandeler2018-03-131-1/+9
|/ | | | | | | | | | | While we could already assign arrays to variant properties, these would not have list semantics when merging modules, so this fills a gap in our type system. [ChangeLog] Added new property type "varList". Change-Id: I54581119f60582f2b11290e13cd4920fd72f55a1 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Add a location to errors in conditions of Properties itemsChristian Kandeler2018-02-231-2/+11
| | | | | | | These can be exceedingly difficult to debug otherwise. Change-Id: Ie3bc42fbd60e11be105fc23624c77a623dc5f1aa Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Merge 1.10 into masterChristian Kandeler2017-12-151-2/+15
|\ | | | | | | Change-Id: Iab942ed25d06038cf8c172eb70dcd8e9a720e1c8
| * Fix regression resolving exported paths defined in the exporting productChristian Kandeler2017-12-131-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit aa1c500411 inadvertently changed the behavior for cases like this: DynamicLibrary { property path inclPath: "." Export { cpp.includePaths: [product.inclPath] } } Before that patch, the base dir for resolving the include path was the exporting product, afterwards it was the importing one. This patch restores the original behavior, which is the intended one. Change-Id: I8a56cff1163e7fc87361b5ab5e9cbd527b53b79b Reviewed-by: Jake Petroules <jake.petroules@qt.io>
| * Fix crash when "original" is being misusedChristian Kandeler2017-12-081-0/+7
| | | | | | | | | | | | | | | | We simply assumed the value would be a module property. Task-number: QBS-1255 Change-Id: I3994f6db62f64ed44cb4d01f0938bc2d536fb3f3 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | Do type checks and conversions also for Probe propertiesChristian Kandeler2017-11-301-12/+24
| | | | | | | | | | | | | | | | | | Due to the unusual the way the configure script sets the properties of the Probe item (i.e. not via a binding), we have to do the type conversion explicitly for these. Change-Id: If6a1dedabde4846de56c1fbd8eaf725035a66368 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | Modernize variable declarationsDenis Shienkov2017-11-301-2/+2
| | | | | | | | | | | | | | | | Use 'const' and 'auto' keywords more where static_cast is used. Change-Id: I60152b90fe5e44aa1ca513b43f133e604ed6417f Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
* | corelib: Gather string constants in central placeChristian Kandeler2017-11-291-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The same string literals appeared over and over again in the code base, causing redundancy in the sources as well as at run-time. We now give them a name and make sure they get instantiated at most once. String literals that occur only once are converted from QLatin1String to QStringLiteral unless they appear only in contexts that make use of QLatin1String overloads or they are clearly outside of any hot code paths. This seems to result in small, but measurable performance improvements, even if we assume the 1% changes to be noise: ========== Performance data for Resolving ========== Old instruction count: 3266514138 New instruction count: 3209355927 Relative change: -2 % Old peak memory usage: 29649896 Bytes New peak memory usage: 29436264 Bytes Relative change: -1 % ========== Performance data for Rule Execution ========== Old instruction count: 3367804753 New instruction count: 3319029596 Relative change: -2 % Old peak memory usage: 19577760 Bytes New peak memory usage: 19091328 Bytes Relative change: -3 % ========== Performance data for Null Build ========== Old instruction count: 608946535 New instruction count: 604566001 Relative change: -1 % Old peak memory usage: 14606384 Bytes New peak memory usage: 14579936 Bytes Relative change: -1 % Change-Id: Ia055a52e0a4b6fe6fd0f1e7ba4bfa583cba1b0ef Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | Fix build with Qt 5.6Christian Kandeler2017-11-281-0/+1
| | | | | | | | | | | | | | | | The header defining the qAsConst replacement was not included in all places where it was needed. Change-Id: I84fc98982d77a85cf9d5af30fb4e8587085c349b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* | Replace more loops with range-forJake Petroules2017-11-271-2/+1
| | | | | | | | | | | | | | | | ...or raw iterators for reverse iterations. Change-Id: I62a110ceeefaf70aaa41f6fb09d811f0eac05657 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Use nullptr to initialize the pointersDenis Shienkov2017-11-201-2/+2
| | | | | | | | | | | | Change-Id: I59d743f585410cb5c00d36a7b6f9a3e9d696d19e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | STL compatibility: use size() instead of count()Jake Petroules2017-11-151-1/+1
|/ | | | | | | This is a simple find and replace with manual sanity check. Change-Id: Ia733befe7885dc3c643d5c84e151312bfd86a3c6 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Fix the outer value for Properties itemsJoerg Bornemann2017-11-101-28/+37
| | | | | | | | | | | | | The outerItem we created contained just one property and was quite fragile when the 'outer' source code contained references to other properties, especially whenever item inheritance was involved. We now directly obtain the value of outer as soon an alternative requests it. Task-number: QBS-1239 Change-Id: I07f9ff85f33b445515b97f7c6f3d4f917fe3ccc8 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Fix evaluation of Properties.conditionJoerg Bornemann2017-11-081-84/+81
| | | | | | | | | Use the same code path for the evaluation of Properties.condition and the actual values. Task-number: QBS-1240 Change-Id: I1cfb2e13349d73bf347bf90ee5aef4b0835630f6 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* SVConverter: Bail out early if the importScope is erroneousJoerg Bornemann2017-11-081-8/+7
| | | | | | | This simplifies the code quite a bit. Change-Id: I07a6667276650c4b4d17bd667dd9f8f1c0f753aa Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* SVConverter: Factor out the creation of the extra scopeJoerg Bornemann2017-11-081-33/+47
| | | | | | | Clean up the handler function for JSSourceValue objects. Change-Id: I04fd79c8c03016c5656f7f392e0e27388215e928 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Remove unused Logger from EvaluatorScriptClassJoerg Bornemann2017-10-131-3/+1
| | | | | | Change-Id: Iea8fbf520bfce086362aa86fc5cc1ae17db216cc Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Merge 1.9 into masterChristian Kandeler2017-10-051-8/+5
|\ | | | | | | | | | | This is intended to be the last merge from 1.9. Change-Id: I7b9dec70a50726f4ed2d54152eab472f2c6b74ec
| * Fix usage of outer within Properties blocksJoerg Bornemann2017-10-041-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In EvaluatorScriptClass we're cloning the value that's referenced by "outer" and leave out the list of alternatives. This custom cloning code was missing the defining item of JSSourceValue, which led to an error if the outer item was dependent on some other property. Now, we create a full clone and clear the necessary members. This ensures we do not have to adjust this code if another member is added to JSSourceValue. Task-number: QBS-1205 Change-Id: I59596894f365fa5207490922ee60959e221102b1 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Use range-based for loop in SVConverter::handle(JSSourceValue*)Joerg Bornemann2017-10-051-9/+7
| | | | | | | | | | | | | | | | ...and remove a superfluous indirection to clean up the code a bit. Change-Id: Ibb600f129c324519ce7f9513e7e6551b7a4288d4 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Use std::vector as container for JSSourceValue::AlternativeJoerg Bornemann2017-10-051-1/+1
| | | | | | | | | | | | | | | | QList is an inept container for a class as big as Alternative. This also removes the need for qAsConst in several places. Change-Id: I742c3f9af607eeb7825f8e4eab2e3d040723e543 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Fix objectId format in EvaluatorScriptClass::resultToStringJoerg Bornemann2017-09-221-1/+1
| | | | | | | | | | | | | | | | Use base 10 for number to string conversion. In all other places we output the objectId as decimal number. Change-Id: I7475acce0b8d195dd9db0a92758a2b9a0e45cac0 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | Add missing override keywordsJoerg Bornemann2017-09-191-3/+3
| | | | | | | | | | Change-Id: I647a04501fbc279d0434d9b8a6160dad1a4f907e Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | Centralize path property resolutionJoerg Bornemann2017-07-101-8/+11
|/ | | | | | | | We had two places where path properties were resolved. Centralize the code in the EvaluatorScriptClass. Change-Id: Ia8a34af912738f381fbe6016f8af1c05c3c746ed Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Merge 1.8 into masterChristian Kandeler2017-06-091-2/+9
|\ | | | | | | Change-Id: I2fcb2113a24c8807467aa03aa3e7590d53761706
| * Remove superfluous nullptr check in SVConverterJoerg Bornemann2017-06-021-1/+1
| | | | | | | | | | | | | | | | We do not need to check itemOfProperty for nullptr, because it is always provided. Other code paths already use this variable unconditionally. Change-Id: Ibf4cd79aa0579361300cd6b6734b15c49bd1e6ec Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
| * Fix lookup of shadowed parent propertiesJoerg Bornemann2017-06-021-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider the following example Project { name: "project" property string projectName: name Product { name: "product" property string foo: projectName } } The foo property is supposed to have the value "project". Instead it had the value "product". EvaluatorScriptClass::property() and SVConverter assume that data->item is the item that's attached to the QScriptValue object. That was not the case when a property was automatically looked up in the parent item. Task-number: QBS-1117 Change-Id: I21d4cc4106ae631730cd34fe352459d311b09501 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Ensure every module property is tracked when evaluatingJoerg Bornemann2017-05-291-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When evaluating a property we take note of the module properties it references. To make that work in every circumstance every module item must have the name property set before evaluating any properties. Also, for debugging it's extremely helpful if every created item has a location assigned. Add sensible locations for newly created items. The special item containing the outer property and items for setting parameters had the type ModuleInstance which is wrong. Add new dedicated item types Outer and ModuleParameters Change-Id: I5a58a02734f3809525c2752b5b6fb4358f8b286b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Replace QStack with std::stack/std::vector depending on usage patternsJake Petroules2017-05-291-3/+3
| | | | | | | | | | Change-Id: I77dc191beab69474fc8f8435f173e657861eec01 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* | Improve dependency tracking between module propertiesChristian Kandeler2017-05-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On the group level, we evaluated too many properties, because we would pull in dependencies of dependencies, e.g. not only qbs.architecture, but also cpp.qbs.architecture etc. On the other hand, we also did not find all dependencies between properties, because Export items were not properly handled. The benchmarker tool run on qbs itself says: ========== Performance data for Resolving ========== Old instruction count: 2802829713 New instruction count: 2431763918 Relative change: -14 % Old peak memory usage: 22623344 Bytes New peak memory usage: 21095328 Bytes Relative change: -7 % The real-world numbers for larger projects seem to be significantly higher; with the Qt Creator super project, I am observing a 30% speed-up on my machine. Change-Id: Ifbff4a01ef6b5cf5801961a168b79a31d8c6b220 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* | Replace QSharedPointer/QWeakPointer with std::shared_ptr/std::weak_ptrJake Petroules2017-05-231-7/+7
| | | | | | | | | | Change-Id: I2915c578968bed425a8d8b617b56df88ed3f2882 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Add missing override specifiersJoerg Bornemann2017-05-091-1/+1
| | | | | | | | | | | | | | This fixes clang's -Winconsistent-missing-override. Change-Id: Ia052b74a869b4532f106d4490650945677e6b153 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | Support enumeration of EvaluatorScriptClass-provided objectsJoerg Bornemann2017-05-021-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | Implement QScriptClassPropertyIterator to support enumerating over properties of JS objects that have an Item representation. We can now create QVariantMaps from Item objects by calling QScriptValue::toVariant. JSON.stringify and 'for (i in obj)' now also work properly. Task-number: QBS-693 Change-Id: I7758ed61708dde5dd71af7ab2ca24232d0341a68 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Remove superfluous includesJoerg Bornemann2017-04-281-3/+0
| | | | | | | | | | Change-Id: I22251d51617d4091287a986a9aa43beb52c1ab04 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | Merge caches with same key in EvaluatorJoerg Bornemann2017-04-261-13/+8
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reduce hash lookups and memory footprint. ========== Performance data for Resolving ========== Old instruction count: 2465977485 New instruction count: 2457362647 Relative change: -1 % Old peak memory usage: 21248960 Bytes New peak memory usage: 21237680 Bytes Relative change: -1 % ========== Performance data for Rule Execution ========== Old instruction count: 4898426038 New instruction count: 4857983226 Relative change: -1 % Old peak memory usage: 27604240 Bytes New peak memory usage: 27593424 Bytes Relative change: -1 % ========== Performance data for Null Build ========== Old instruction count: 4509789474 New instruction count: 4490616946 Relative change: -1 % Old peak memory usage: 30680456 Bytes New peak memory usage: 30670784 Bytes Relative change: -1 % Change-Id: Ie613447cf9da4bc3d2bfdab42c9a9b5ace643540 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Add Item::ownProperty for symmetry and use it where appropriateJoerg Bornemann2017-03-231-1/+1
| | | | | Change-Id: I721f0db1dde46eea9bf8de74a3052f76bd52dd4b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Remove superfluous Evaluator::importScope callJoerg Bornemann2017-01-121-1/+1
| | | | | | | We're already fetching the same import scope four lines up. Change-Id: I08f1f389127c6df6624518e9170a8d523dd47d32 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Fix const-ness of Logger in Evaluator and EvaluatorScriptClassJoerg Bornemann2017-01-111-1/+1
| | | | | Change-Id: I9ad1126c763086235aa35ee8c9a6fca21663a4d2 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Remove superfluous QScriptEngine::currentContext callsJoerg Bornemann2017-01-111-8/+8
| | | | | Change-Id: Id9bf393a0dd3ae9e57af52accb024d42ed1a932a Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Remove superfluous QScriptClass::engine callsJoerg Bornemann2017-01-111-2/+2
| | | | | | | We have the engine member for that. Change-Id: I59cec08bbd2cb4bbab119b307490f599634b7d5b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Remove superfluous m_sourceValueStack from EvaluatorScriptClassJoerg Bornemann2017-01-111-7/+4
| | | | | Change-Id: Iae79a5e0deb65e45a43de630dde150fb070754d9 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>