-
Notifications
You must be signed in to change notification settings - Fork 346
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
Simpler gmt_*_module.[ch] files #3133
Conversation
I also think we could avoid the |
I will simplify the shell script next, it ought to be even less code than 65%. |
We need a test on Windows here of course since we are messing with the dark shared library side. |
I breaks my MB supplement again |
Can you be more specific? It did not break my gsfml supplement even though I did not make any changes there, only to GMT. My changes should not have any effect on other supplements since you are not calling things in gmt_core_*.c etc. |
There are still parts of the module.h files that are created by the script but that probably could just be part of a static include file. For instance, these prototypes:
do not change, except when we very infrequently introduce a new module. It is not a problem for us to maintain this include file. What does change are things like the define statements at the top of each module: THIS_MODULE_PURPOSE, THIS_MODULE_KEYS, THIS_MODULE_NEEDS. For that reason we need a script to create the module structure. However, if we have the list of modules in that static file, the script would be much simplified since we can use the static file for the list of current modules and hence source files. |
Yes, I am. I have a But I have restored them. Now it builds again ... till next |
I know you have mbgmt_module.c|h but none of those are calling things in gmt_core_module.c, right? |
I would like to break up the gmt_supplements_module.c|h stuff since it is an artificial collection of some supplemental dirs. To simplify life for other supplements (mg, gsfml) it would be better if each supplement had these things and that cmake helped. We can still place stuff in a single supplements.so for the GMT approved supplements, but not make the code part special via gmt_supplements_*.c|h. |
Take that partially back: I think the only good solution for supplemental dirs will result in individual so/.dll files. If so then we are truly liberated from maintaining gmt_supplements_*.? files in the core directory. |
No, they don't. But things were not working and didn't know why. Perhaps it was only the BUILD_EXTRA_DIRS thing. |
OK, I will use this branch to create modules.h files for core and for each supplement dir, then a small script that builds the glue. |
Hi @seisman, each of the supplement CMakeLists.txt files have lines like this:
I would like to add the same to the main src file with name "core", and then have gmt_shared.h.in files in each source directory containing statements like this:
in order to automatically create the functions via cmake. Do you think the
in each directory (src, src/*) properly configure and build the correct sources? I am trying to find out that answer before doing all the work and really finding out... |
Yes, |
Here is my plan for eliminating users and developers from dealing with things like gmt_make_module_src.sh and the hundreds of lines of code it produces:
There are two steps that are nontrivial or unclear at this point.
Do @joa-quim or @seisman see anything flawed in this scheme? I think if this can work we avoid having to worry about running things like gmt_make_module_src.sh manually, and can much more easily document what it takes to make a new supplement dir (just copy gmt_shared.h and gmt_glue.?.in from any supplement and edit the first file. |
Perhaps it is possible to do
for the subdir CMakeLists.txt files so that there is no need to place a gmt_shared.h.in files (and gmt_shared.c.in) in each directory, only in src? |
I'm a little confused. Are you talking about gmt_shared.h or gmt_glue.h? |
Sorry (names are changing in my head), above I mean gmt_glue.?.in since gmt_shared.h is a static file we maintain manually. The idea is to use the *.in files from src repeatedly in each subdir to make slightly different include files and C files. |
BTW, probably for similar reasons, I see this having snuck into src/CMakeLists.txt:
That should not be necessary either. |
Yes, it's doable. |
OK, close to working but family insist on going swimming. Back in the afternoon. I committed all my changes to this branch in case you want to try to see. I still fail on a few externs but very close. No longer using gmt_core_module.?, but gmt_modules.h (static), gmt_glue.?. |
PS. I have not touched the supplements yet on this since the above scheme means breaking up supplements.so and the need to find those individual so files. So only core testing for now. |
You didn't commit the gmt_shared.h file. |
All julia tests pass again |
We are good to merge into master... Why is the WIP check in progress, @seisman ? |
* Rename SUPPL_* toSHARED_LIB_* * Update gmt_glue.c.in * Update src/CMakeLists.txt Co-Authored-By: Dongdong Tian <[email protected]> * More documentation * Move settings closer to library building Co-authored-by: Dongdong Tian <[email protected]>
Do we still need this implemented? |
Not sure, maybe. There are three kinds of "supplements":
See #3130 for some thoughts. For type 2 above to work, the idea was to use configure_file with gmt_glue.c.in and make src/newsuppl/gmt_gsfml_glue.c which means there has to be a gmt_gsfml_moduleinfo.h available. It would be slick if that was handled by GMT CMake, but if it adds to much complication... THen the 3rd option, and possibly the solution for type 3, is to let gmt --build-glue=supplementname create those pieces. |
I thought first of gmt-config, but it is a script that may not be ideal for all environments (e.g., Windows). |
Are gmt_glue.c and gmt_moduleinfo.h required for unofficial supplements? As I understand it, if a supplement package doesn't have gmt_glue.c and gmt_moduleinfo.h, users still can access all modules in the supplement package, except that these modules are not listed in gmt --help or gmt --show-modules. Am I right? |
The builds break after merging #3165 with following errors:
In commit d2016b4, you changed
to
|
Yes, you are right. There are two things:
then we need to be able to access the KEYS for those modules in the library. Otherwise we cannot do the above since we would not know how to hook the G matrix into the mbgrdtiff command line options. This is the job of API functions GMT_Encode_Options and GMT_Expand_Option. So that is why I want to encourage having the glue and making it super-painless for those developers to do this. |
Anything else for this branch you are thinking of, @seisman ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks good to me.
Description of proposed changes
I have abstracted the key part of the various lookup functions and added them to the gmt_api.c. Now, the core or supplement-specific look-up function simply are shells that pass in the relevant array of module information into the main gmtapi functions. This reduced the code for gmt_module_*.[ch] by 22%.