Determine DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR value at compile-time or runtime ?

32 views
Skip to first unread message

Benjamin Golinvaux

unread,
Apr 10, 2020, 6:39:47 AM4/10/20
to emscripten-discuss
Hello,

I am writing a library using Emscripten and I stumbled on issues related to users using different values for DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR when building our lib.

I was about to add a note that mentions the mandatory usage of -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 but I thought it would be more elegant to have the library adapt itself (the client of the library have to build it on their own)

I was wondering if I could somehow introspect the settings at compile time (with a #define macro) to find out the value of this flag or, if no macro is provided, at runtime (worse, but sufficient for my needs)

I think I could use an awful hack where I examine the dom and try to register a dummy event callback and check its value, but I would like to avoid that if possible.

Thanks in advance for any information on this topic.


Benjamin

A K

unread,
Apr 10, 2020, 7:03:44 AM4/10/20
to emscripte...@googlegroups.com
Hi Benjamin,

I would be happy if Emscripten had something like what you propose, but just let me share how we deal with these issues:

If you use cmake then the Emscripten toolchain file defines EMSCRIPTEN_VERSION (https://github.com/emscripten-core/emscripten/blob/ceacba11/cmake/Modules/Platform/Emscripten.cmake#L128), which you can use to direct compilation through cmake=>preprocessor defines. You unfortunately still have to check the changelog or Emscripten history manually to find out when each feature was introduced/changed.

For the find event target behavior change in particular, we have the following in our code:

if (EMSCRIPTEN_VERSION VERSION_GREATER_EQUAL "1.39.5")
    set(EMSCRIPTEN_HAS_NEW_DOM_ELEMENT_LOOKUP_BEHAVIOUR ON)
else()
    set(EMSCRIPTEN_HAS_NEW_DOM_ELEMENT_LOOKUP_BEHAVIOUR OFF)
endif()

Which is later exposed to the C++ preprocessor using configure_file and a #cmakedefine01.

András


--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/0f9d5629-8597-4a76-a1e2-d03db349de16%40googlegroups.com.

Benjamin Golinvaux

unread,
Apr 10, 2020, 8:44:46 AM4/10/20
to emscripten-discuss
Hello András,

Thanks for your reply. Unfortunately (unless I am missing something), even though the version can be checked, previous versions (such as the 1.38.47 I am using) can be used with DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR set to 0 (or unset) or 1.

I was hoping for an extra macro available to the C/C++ preprocessor...

Your tip might be useful in many other situations, though!

Best

Alon Zakai

unread,
Apr 10, 2020, 11:25:40 AM4/10/20
to emscripte...@googlegroups.com
Another option is RETAIN_COMPILER_SETTINGS and then calling emscripten_get_compiler_setting(), see settings.js.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

Benjamin Golinvaux

unread,
Apr 14, 2020, 8:27:40 AM4/14/20
to emscripten-discuss
Thank you !   I wasn't aware of this. Very handy.


 
Reply all
Reply to author
Forward
0 new messages