Commit Graph

81 Commits

Author SHA1 Message Date
Ulf Hermann 51f6d418fa qmlcachegen: Move resourcefilter.cpp into QmlCompiler
For backwards compatibility, a replacement for qmlcachegen will need to
provide the same functionality.

Change-Id: I22664230ea636d384190122223d15819ebee930c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-20 17:19:26 +02:00
Ulf Hermann 4f44f82b9f QmlCompiler: Rename ResourceFileMapper
The file class names should start with a common prefix.

Change-Id: I5e014c103668a1bc73d359b00a1dda33e5637a79
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-05 14:58:52 +02:00
Ulf Hermann 767dd738d3 Long live libQtQmlCompiler!
Move all the code from tools/shared into src/qmlcompiler and build a
static library from it so that we can re-use it in external tools.

Change-Id: I7c8d8e59063dc7c711f4072f103a01095e6f5997
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-05 14:58:32 +02:00
Alexandru Croitor 26c5243491 Merge remote-tracking branch 'origin/dev' into wip/cmake
Conflicts:
	dependencies.yaml
	src/qml/qml/qqmlengine.cpp

Change-Id: I6a73fd1064286f4a2232de85c2ce7f80452d4641
2020-03-12 15:03:03 +01:00
Simon Hausmann 8ab237edf1 Restore offset/length in QQmlJS::DiagnosticMessage
This is needed in a few places outside of declarative, so this change
restores the loc member in DiagnosticMessage and moves
QQmlJS::AST::SourceLocation into common's QQmlJS namespace/directory.
QQmlError is unaffected and retains only line/column.

Amends d4d197d062

Change-Id: Ifb9d344228e3c6e9e26fc4fe112686f9336ea2b2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-03-02 10:35:50 +01:00
Ulf Hermann cc759804aa Avoid deprecated non-q-prefixed hex() function
Use Qt::hex() instead.

Change-Id: I46bc2f2006ce860cd938a86432783011365c8164
Reviewed-by: Liang Qi <liang.qi@qt.io>
2019-12-17 09:47:15 +01:00
Alexandru Croitor c2f8b9535d Merge remote-tracking branch 'origin/dev' into wip/cmake
Removed dependencies.yaml because we don't use it yet in wip/cmake.
Fixed conflict in qmlcachegen.cpp.

Change-Id: Ie1060c737bee1daa85779903598e5b6d5020d922
2019-10-14 19:02:37 +02:00
Alexandru Croitor 6a0bb9a7d6 Merge remote-tracking branch 'origin/wip/qt6' into wip/cmake
Change-Id: I4a91928610f79c8e21a05781953ffa41508c828a
2019-10-11 16:21:42 +02:00
Qt Forward Merge Bot a510c9c9f4 Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I801567c11fcc3244a1ee7dabeb5079d49fc5c3a1
2019-09-22 22:29:02 +02:00
Simon Hausmann d5f3e7a7e3 Fix regression when using CONFIG+=QtQuickCompiler and .qrc files in subdirs
Commit 41864db3b6 removed the processing
of .qrc files that removed .qml/etc. files. Since the chaining of
resources remains critical to ensure that the cached compilation units
are loaded, the build system copied the input .qrc file to a new one.
That mere copying caused the build to break when the copied .qrc file
was not in the same directory as the original one, as file paths within
the .qrc file are interpreted as relative to the .qrc file, which was
now in a different location. To fix this, this patch brings back the
"filtering" code that rewrites the paths to the source files in the .qrc
file.

Fixes: QTBUG-78253
Change-Id: Ie1d56f3248e713a964260bc2da37c9374f7b6a36
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-09-19 11:32:23 +02:00
Simon Hausmann 83be211744 Merge remote-tracking branch 'origin/wip/qt6' into dev
Change-Id: I10c4b7fcfa0397d999d45e310c2f8f051d57d4d2
2019-09-19 08:53:00 +02:00
Simon Hausmann 41864db3b6 Fix *.js files disappearing from RESOURCES when not using QtQml
[ChangeLog][QtQml][Important Behavior Changes] Using the Qt Quick
Compiler would exclude the original .qml files from the resource system.
This made it impossible to change the Qt library binary later as the
program binary was tied the to the exact Qt version. In addition
sometimes unrelated files (QTBUG-73669) were removed. For the latter
scenario, retain and skip options were added for the Qt Quick Compiler.
In Qt 5.15 the Qt Quick Compiler does not remove the input files
anymore. All files are retained and the compiler merely adds the more
efficient binary representation to the application.

Task-number: QTBUG-73669
Change-Id: I5a523bfc69d4f48a1451bd880616c82fd73b8d15
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2019-09-09 07:52:25 +02:00
Ulf Hermann 2746518c76 Merge remote-tracking branch 'origin/dev' into wip/qt6
Conflicts:
	.qmake.conf
	src/qml/qml/qqmlengine.cpp
	src/qmlmodels/qqmlmodelsmodule.cpp

Change-Id: Id60420f8250a9c97fcfe56d4eea19b62c6870404
2019-09-05 11:08:59 +02:00
Tasuku Suzuki 6b106d4463 Fix build without features.temporaryfile
Change-Id: If990efb64a4117bc7624062fededa7ce6a910f14
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-08-19 22:06:26 +09:00
Leander Beernaert 494dc05ea1 Extend qmlcachge to support --retain with CMake
Add missing code so we can use the --retain argument when running
qmlcachgen from a CMake project.

Change-Id: I0b4a2f2ea6c424ba698ee178a332f585271b945e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-08-13 07:52:51 +00:00
Leander Beernaert 059d792264 Add support for generating qmlcache_loader without qrc
Added support for response file expansion to qmlcachegen.

Add the option --standalone-namespace to qmlcachegen so we can
generate qmlcache_loader from a collection of resource paths
instead of operating on qrc files. This is necessary, since the
namespace identifier is extraced from the qrc file name, which
we no longer have.

This pach was made in order to tend to the cmake port's version of
qtquickcompiler support which does not rely on qrc files.

Change-Id: If15190f3492e6695f5a6e61bf8816998760541f7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-31 12:33:44 +00:00
Simon Hausmann 880a143eb5 Merge remote-tracking branch 'origin/dev' into wip/qt6
Change-Id: I4476733af61fcf3a2af1d121a4585c3fae1c240e
2019-07-12 20:36:48 +02:00
Ulf Hermann f5e4f07841 Disentangle includes and namespaces
Avoid using namespace in headers and include only the headers we
actually need.

Change-Id: I526a0f874dc09b07693fd87070665be396d3b637
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-11 11:14:54 +02:00
Ulf Hermann 9a8dd594b5 Merge JSCodeGen and QQmlJSCodeGenerator
Change-Id: I2219cba0dd3782cb2e0b09b8f3c4d5472e6e5d7e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-10 18:22:40 +02:00
Alexandru Croitor 9c5af084a9 Merge remote-tracking branch 'origin/dev' into wip/qt6
Change-Id: Ifc24fbd99ee216e528a213fdbfd2892b3df419fe
2019-07-08 11:36:14 +02:00
Alexandru Croitor 1c5c5f7aad Fix Qt6 build in preparation of qt5 submodule update
Fixes the QTextStream usages.

Change-Id: I0c009a82fb644a9f3c3d42ec410d18b680977f23
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-08 05:56:02 +02:00
Ulf Hermann 40ded579bd Simplify codegen error handling
There can only ever be one error, either a syntax error or a reference
error. We record the error type as we want to get rid of the virtual
throw<X>Error methods in favor of an explicit compilation result.

Change-Id: Ie228490aad8efb7885083f6485f931299567f54c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-04 16:03:36 +02:00
Ulf Hermann e72637deed Move saveToDisk into SaveableUnitPointer
This way we can keep the flag mutilation closely local to the place
where we write the data. Also, SaveableUnitPointer doesn't need a full
CompilationUnit this way.

Change-Id: I01872e4c406cb2ccbaa1fa35325cc063b1e8a7df
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-24 11:13:05 +02:00
Ulf Hermann d4d197d062 Simplify errors and diagnostics
We only need two classes to describe all possible diagnostics:

* A low-level private POD DiagnosticMessage. This is easily copied and
  passed around internally. It doesn't need to adhere to a stable API
  and it doesn't carry any extra baggage.

* The high-level public QQmlError with its stable interface. This can
  internally also use a DiagnosticMessage as storage.

Change-Id: I52be88d9b5d9855a661b8032b01eedb43a0fb0b3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-14 19:08:51 +02:00
Ulf Hermann ae1c2375f5 Add abstraction for temporarily setting StaticData when saving
The StaticData flag needs to be saved to disk, but removed again
afterwards so that we can free() the malloc'd data. This also allows us
to avoid copying all the data into a byte array before saving.

Change-Id: I96513f8d98acf0ea0b4514d96376b487e8444917
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-17 10:34:31 +00:00
Ulf Hermann 7f7d87c68d Split CompiledData::CompilationUnit in two
We need a CompilationUnit that only holds the data needed for
compilation and another one that is executable by the runtime.

Change-Id: I704d859ba028576a18460f5e3a59f210f64535d3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-16 12:09:23 +00:00
Ulf Hermann a8b3536d6e Move compileModule() into qv4codegen.cpp
This is a better fit for the method. In turn, remove all the
V4_BOOTSTRAP conditions from qv4engine_p.h and make sure we don't
include or compile it in bootstrap mode.

Change-Id: I5933b0724e561313ca20c420b83e4d70e63bddf5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-08 12:05:30 +00:00
Qt Forward Merge Bot 187b2e0efc Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I2f0b4f8543a448c9acffe0932e0fd67c0b7412f4
2019-03-27 10:27:56 +01:00
Simon Hausmann 516523750d Enable lookups for imported scripts and worker scripts
This is straight-forward to enable, with the minor adjustment that we
need to handle the case where a global lookup is done without a calling
qml context (worker script). We don't know at compile time whether a
script will be imported directly or used as a worker script, so we have
to generate the global qml lookup instruction regardless and handle it
at run-time.

Change-Id: Ia033afa214d919d906c676498dd3eceb1c5639d8
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-03-25 10:26:11 +00:00
Qt Forward Merge Bot a1e38651ce Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	.qmake.conf
	src/qmltest/quicktest.cpp
	tests/auto/qml/qmlcachegen/qmlcachegen.pro

Change-Id: I70e96e8817d59647f876b8b77b30cdeede8f0662
2019-03-25 10:13:23 +01:00
Simon Hausmann 78888f485f Enable lookups in QML files when compiling ahead of time
This should have been enabled in the series earlier when for
QTBUG-69898.

Change-Id: Ide7507d5dcf439463c22b631d49d654624737d1f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-03-22 12:42:37 +00:00
Simon Hausmann 90a08b0c52 Fix memory "leaks" in qmlcachegen
The CompilationUnit class owns the unit data. An exception was made in
bootstrap builds, where it was up to the caller to free the memory. This
lead to cases in qmlcachegen where we didn't free the memory. This is
best fixed by unifying the behavior.

This fixes the build when using an ASAN enabled build, as the runtime
aborts after calling qmlcachegen due to "leaks".

Change-Id: I8b55b4e302a9569a1d4e09eeb488c479368b50f0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-03-22 12:42:32 +00:00
Qt Forward Merge Bot 7a349710cc Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	src/qml/compiler/qqmltypecompiler.cpp
	src/qml/compiler/qv4bytecodehandler.cpp
	src/qml/compiler/qv4codegen.cpp
	src/qml/compiler/qv4compileddata_p.h
	src/qml/compiler/qv4compiler.cpp
	src/qml/compiler/qv4instr_moth.cpp
	src/qml/compiler/qv4instr_moth_p.h
	src/qml/jit/qv4baselinejit.cpp
	src/qml/jit/qv4baselinejit_p.h
	src/qml/jsruntime/qv4function.cpp
	src/qml/jsruntime/qv4vme_moth.cpp

Change-Id: I8fb4d6f19677bcec0a4593b250f2eda5ae85e3d2
2019-03-21 10:59:45 +01:00
Simon Hausmann 5cfccf3089 Remove dead compile time QML context/scope property and id object code
After enabling lookups in QML files, we can remove all the code that
tries to deal with (type) compile time detection of access to id objects
and properties of the scope/context object. This also allows removing
quite a bit of run-time code paths and even byte code instructions.

Task-number: QTBUG-69898
Change-Id: I7b26d7983393594a3ef56466d3e633f1822b76f4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-03-20 09:16:52 +00:00
Qt Forward Merge Bot e912c646e2 Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	src/qml/compiler/qv4codegen.cpp

Change-Id: I66b7db42bf208855889094ace0267326595ce03c
2019-03-18 13:49:23 +01:00
Simon Hausmann 24ec7b6c83 Fix up global name determination when compiling ahead of time
The list of names is still suboptimal, but at least it's shared now.

Task-number: QTBUG-69898
Change-Id: I16c9839c4a1f097053b28caea894b67757972826
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-03-15 13:04:46 +00:00
Ulf Hermann b84927dc2b qmlcachegen: Eliminate foreach
Change-Id: Ic13e5af7ddb92cf5988988ebe1c2b7470a5f8c1e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-04 14:29:09 +00:00
Ulf Hermann 21ffde85a1 Add option to retain sources when generating QML cache
By default any .qrc files are filtered and QML and JS sources dropped
when generating the cache. The new QTQUICK_COMPILER_RETAINED_RESOURCES
option allows the specification of .qrc files to be kept as they are.
The source fils specified in them will be available to the application.

Change-Id: If45bcd95c29fe4b91f5817573964ff55b1db8a00
Fixes: QTBUG-72430
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-04 14:13:49 +00:00
Jüri Valdmann 8b418d9be7 Clone ContextType::Global as ContextType::ScriptImportedByQML
Add new enum value QV4::Compiler::ContextType::ScriptImportedByQML, which
behaves exactly the same as ContextType::Global. A follow-up patch will change
the behavior slightly.

Task-number: QTBUG-69408
Change-Id: I20d27804fd1433f2229704546bcd78a0ac108c01
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-11-01 15:07:01 +00:00
Simon Hausmann 4b2b1fc121 Add support for compiling ES modules ahead of time
This is also pretty straight-forward by adding .mjs as supported
extension in the qmake and cmake support.

This also tweaks qv4engine.cpp to share the same module compilation
function across all code paths.

Change-Id: Ia0e23c78a794f2330ecf8f991ee6ea948f4ac89d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-08-17 11:06:18 +00:00
Simon Hausmann 193db4c526 Clean up internal QML unit creation API
Since the callers always end up assigning the returned unit pointer back
to the compilation unit's data member, we might as well do that inside
the function and return void instead.

Change-Id: I7a7f3e7a0c89ffe2f9474149fcf61736609b363d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-07-31 17:08:37 +00:00
Simon Hausmann 8e45393d10 Fix import of precompiled .js files
Loading those must not fail the file relocation test, so set the source
file names to empty, as we also do for .qml files.

Also added tests for all the scenarios: no embedded file paths for AOT
files but absolute paths for run-time created cache files.

Change-Id: I3fc92e89cfd0da512afeac22bd0da3e915ec46ea
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-07-31 07:28:03 +00:00
Qt Forward Merge Bot dd333172e2 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I800f39ea59efd6049d3226ec27b8ecb3f6e9ae28
2018-06-29 01:02:07 +02:00
Simon Hausmann d6177808d6 Clarify error message when using eval in signal handlers
Task-number: QTBUG-64024
Change-Id: If8f749ef9ec072928cb352ad7cd4dcf140b6ed53
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-06-28 07:56:46 +00:00
Simon Hausmann 1e7cd1acf6 Remove obsolete option
The check-if-supported option does not make sense anymore since the
generated output is cross-platform.

Change-Id: If7802267b51b445d2e41387d556a344616e9afc8
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Rolf Eike Beer <eb@emlix.com>
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
2018-06-26 08:54:23 +00:00
Liang Qi 6e5251dd3d Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
	src/qml/qml/qqmltypeloader.cpp

Change-Id: If9874faf23e813b05ee4cf042133a528d73ba72a
2018-05-15 15:32:04 +02:00
Simon Hausmann 0a2aaee61c Fix .import within .js files with CONFIG+=qtquickcompiler
When loading a .js file without QQC, we scan the sources and use the
ScriptDirectivesCollector to extract things like .pragma library or
.import ahead of time. That information is passed on to the compilation
unit generator for serialization. When compiling .js files ahead of
time, we also used the same collector, but we forgot to save the data
into the right location before serialization, so we essentially lost the
imports. This patch fixes that by centralizing this code into the
ScriptDirectivesCollector itself.

[ChangeLog][QtQml] Fix regression with .import in .js files not working
when using CONFIG+=qtquickcompiler.

Change-Id: I5413c14b1b8bd3114a997011534fe55cdb7634aa
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-05-11 19:18:45 +00:00
Lars Knoll e9492e7b7b Rename the CompilationMode enum to ContextType
And make it an enum class. The new name fits better, as it's mainly
used to determine the type of the context when parsing. Also already
added the 'Block' value that will be needed.

Change-Id: I70d963b6a0b22db1a3c607cce6bdd2054b29e000
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-02 14:17:13 +00:00
Simon Hausmann 1a3447a040 Clean up manual reference of QQmlTypeData and QQmlPropertyCache
We have a few places in the type loader where we do adventurous manual
reference counting, where getType() returns a raw pointer that has been
addref()'ed and then sometimes somehow we call release() later. Commit
0b394e30bb is an example of where this can
easily go wrong. As a consequence and also in preparation for future
work on the type loader, this patch starts replacing the manual
reference counting there.

Changing the return type from QQmlTypeData *getType() to a
QQmlRefPointer<> itself is not sufficient though, as the implicit
operator T*() will still allow the caller to store the result as a raw
pointer. Therefore this patch removes the "unsafe" implicit extraction
operator.

As a result of that change, other types that are sometimes stored in
QQmlRefPointer are also affected and their usage needs to be adapted
to QQmlRefPointer usage or manual raw pointer extraction with .data().

Change-Id: I18fd40634047f13196a237f4e6766cbef3bfbea2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-04-26 09:56:39 +00:00
Lars Knoll 44cfb771c2 Disentangle some includes by moving QQmlJS::Directives into qqmljsengine_p.h
Change-Id: Iee5a5a9edc8b79649a8f43612584ecf046a9aa2c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-04-25 14:19:23 +00:00