Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving API name/type changes in different versions #33

Open
camnewnham opened this issue Apr 10, 2024 · 1 comment
Open

Resolving API name/type changes in different versions #33

camnewnham opened this issue Apr 10, 2024 · 1 comment

Comments

@camnewnham
Copy link

camnewnham commented Apr 10, 2024

Hello! Thanks for this template. It's been very useful to get started on a plugin.

I started with this template, then have copied in most of the BrowserControl example. I noticed when doing this that the builds started failing for Archicad 25 and 26. This appears to be for a few reasons, but all of them seem to be namespace or function name changes.

For example, ACAPI_Register_Menu in AC26 vs. ACAPI_MenuItem_RegisterMenu in AC27.
Similarly, the JS object classes were formerly DG::JSValue and are now JS::Value.

I am relatively new to C++. Is there a technique for using different names based on AC version? It would be convenient to be able to target multiple out of one project.

Coming from C# the equivalent would be:

#if ARCHICAD_26
using JSValue = DG.JSValue;
#else
using JSValue = JS.Value
#endif

Edit: Looking at this again it seems like quite a bit of work to manage multiple versions as the API seems to have changed a reasonable amount (at least by naming convention) between AC26 and AC27

@camnewnham
Copy link
Author

I've worked around this by adding the following to CMakeLists.txt

if (DEFINED ADDITIONAL_COMPILE_DEFINITIONS)
	add_compile_definitions(${ADDITIONAL_COMPILE_DEFINITIONS})
endif()

Subsequently if using the python build tools, it can be used in the following way:
python Tools/BuildAddOn.py --configFile config.json --acVersion 27 --additionalCMakeParams ADDITIONAL_COMPILE_DEFINITIONS='PLUGIN_VERSION="1.2.3.4";ARCHICAD_27'

And then in code as

#if ARCHICAD_27
...
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant