GDevelop
GDevelop copied to clipboard
Allow single quotes for text litterals in expressions
This allows for using single quotes for text litterals inside of expressions. For example, where before only " \" ' hello ' \" " was accepted, now ' " \' hello \' " ' is too.
This is very useful when working with JSON, where you have no choice but to use double quotes everywhere, and escaping them makes the JSON less readable:
🤮 "{\"myKey\": \"myValue\"}"
✅ '{"myKey": "myValue"}'
Probably a good idea indeed... Can you add various test cases in C++ for this? See ExpressionParser2.cpp in Core/tests (there are not a lot of explanations about how to compile these locally - let me know if you can't find how to do it).
Sorry, I have tried multiple times but never managed to run the C++ tests successfully.
@4ian Ping in case you've forgotten ;)
I totally forgot, I guess I have to check how to compile these tests on Windows. Probably will need an installation of MinGW.
Probably will need an installation of MinGW.
Good, I already have one. I also have the windows subsystem for Linux if that helps. I think I had tried with both WSL GCC, MinGW GCC and visual studio's compiler last time I tried, 1 of them was unable to find basic libraries like JPEG, which seemed to be installed, and the ones that worked (i think MinGW & WSL) either didn't output the DLLs correctly or couldn't compile SFML.
With MinGW GCC:
[build] [100%] Linking CXX executable GDCore_tests.exe
[build] CMakeFiles\GDCore_tests.dir/objects.a(ExpressionCodeGenerator.cpp.obj): In function `ZN2gd26ExpressionParserDiagnostic10GetMessageEv':
[build] c:/code/gdevelop/core/gdcore/events/parsers/ExpressionParser2Node.h:48: undefined reference to `gd::ExpressionParserDiagnostic::noMessage'
[build] CMakeFiles\GDCore_tests.dir/objects.a(ExpressionCompletionFinder.cpp.obj): In function `ZN2gd31ExpressionCompletionDescriptionC1ENS0_14CompletionKindERKNS_6StringES4_jjS4_S4_':
[build] c:/code/gdevelop/core/gdcore/ide/events/expressioncompletionfinder.h:258: undefined reference to `gd::ExpressionCompletionDescription::badParameterMetadata'
[build] CMakeFiles\GDCore_tests.dir/objects.a(ExpressionCompletionFinder.cpp.obj): In function `ZN5Catch6Detail15StringMakerBaseILb1EE7convertIN2gd31ExpressionCompletionDescriptionEEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_':
[build] C:/code/GDevelop/Core/tests/catch.hpp:1174: undefined reference to `gd::operator<<(std::ostream&, gd::ExpressionCompletionDescription const&)'
[build] collect2.exe: error: ld returned 1 exit status
[build] Core\CMakeFiles\GDCore_tests.dir\build.make:646: recipe for target 'Core/GDCore_tests.exe' failed
[build] mingw32-make.exe[3]: *** [Core/GDCore_tests.exe] Error 1
With Clang, it does not manage to detect the system library JPEG and cannot build because of that. Couldn't find a way to install a library for clang.
With MSVC, for visual studio 2019 cmake says that there is no cpp11 support, and for visual studio 2017 there are hundreds of compilation errors with __declspec(dllexport).
Ping ;)
I can reproduce the issue with MinGW. These linker issues are a nightmare 🤦🏻♂️ Not sure what's going on but seems like gcc is scrapping symbols because of optimization, while it should not?
Alright, there was a bunch of GD_CORE_API that were required that I've added :)
- You should be able to compile with MinGW. For launching GDCore_tests.exe, you still need to copy SFML dlls (find them in ExtLibs/SFML/lib inside the build folder) and GDCore.dll (find it in Binaries/Output/Release_Windows).
- We could avoid SFML by removing it entirely.
- We could avoid having to copy GDCore.dll if we avoided to customize the output folder. When the output is not emscription, no need to change the path were the libraries are output I think.
- For Clang, we would need to remove SFML entirely I guess.
- For MSVC, we would need to fix our check for C++11 support - which is guaranteed by all compilers now since a long time.
Give at least a new try with MinGW :) The tests are longer to run on my Windows computer but they pass! GDCore_tests.exe -h gives you a few options.
It compiles now! But...

I've copied the DLLs as instructed:

In which folder did you copy them? I copied sfml-*-2.dll and GDCore.dll into Binaries/build/Core (where GDCore_tests was output) and then I can navigate in this folder with a command prompt and run GDCore_tests. If I try to double click on it, there are other dlls not found (so running from command line is important probably)
In which folder did you copy them? I copied sfml-*-2.dll and GDCore.dll into Binaries/build/Core (where GDCore_tests was output) and then I can navigate in this folder with a command prompt and run GDCore_tests.
I had done the exact same and the executable did not do anything, just instantly closed. When I open it by clicking on it, it popped up the errors. I had copied all files in the same folder as you but moved them to a separate one for the sake of getting all the ones I were supposed to copy onto a screenshot, I never executed it in that folder though only made the screenshot.

I managed to fix the openal error (I had to download openal duh) but now I've got this one:

I don't think i'll be able to get those to work, I'm sorry to have to ask this but could someone at @GDevelopApp/core-engineering-team write those test for me? Thanks
Ping
Ping
I tried building the tests on windows, only to meet failure yet again. With all compilers, I get this error:
FAILED: Core/CMakeFiles/GDCore.dir/GDCore/IDE/Events/EventsVariablesFinder.cpp.obj
../Core/GDCore/IDE/Events/EventsVariablesFinder.cpp:32:19: error: external linkage required for symbol '_ZTIN2gd12_GLOBAL__N_134VariableFinderExpressionNodeWorkerE' because of 'dllexport' attribute
class GD_CORE_API VariableFinderExpressionNodeWorker
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../Core/GDCore/IDE/Events/EventsVariablesFinder.cpp:126:19: error: external linkage required for symbol '_ZTIN2gd12_GLOBAL__N_125VariableFinderEventWorkerE' because of 'dllexport' attribute
class GD_CORE_API VariableFinderEventWorker
^~~~~~~~~~~~~~~~~~~~~~~~~
FAILED: Core/CMakeFiles/GDCore.dir/GDCore/IDE/Events/EventsIdentifiersFinder.cpp.objdentifiersFinder.cpp:32:19: error: external linkage required for symbol '_ZTIN2gd12_GLOBAL__N_136IdentifierFinderExpressionNodeWorkerE' because of 'dllexport' attribute
class GD_CORE_API IdentifierFinderExpressionNodeWorker
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../Core/GDCore/IDE/Events/EventsIdentifiersFinder.cpp:127:19: error: external linkage required for symbol '_ZTIN2gd12_GLOBAL__N_127IdentifierFinderEventWorkerE' because of 'dllexport' attribute
class GD_CORE_API IdentifierFinderEventWorker
^~~~~~~~~~~~~~~~~~~~~~~~~~~
Aha, I FINALLY managed to build them on GitHub Codespaces! 😎

I added a few tests, and found a case that does not yield the expected result