-
Notifications
You must be signed in to change notification settings - Fork 76
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
Semantic Versioning and CLI --version support #51
Conversation
One improvement - now we don't have to update the version in several places... |
@bemcdonnell as long as you are mentioning versioning - it would help as well to have the actual inp file have the engine version in the OPTIONS section. I often get past SWMM5 files and it is hard to figure out what version it matches. It would help parse the INP better - especially those predating SWMM 5.0.013 |
@dickinsonre so are you suggesting we restrict an INP file to run with a specific version of SWMM? |
No, of course not but as i was reading all of the discussion of internal vs external parsing i remembered parsing issues with groundwater and a few other odd sections where a blank, a "*" or the number of tokens per line change the way the SWMM 5 engine builds the data structure. I hope this is clearer, but if you often get inp files from Korea or Vietnam (not to pick on those countries) it would be nice to know what version created the files. |
@dickinsonre: So essentially, which version of SWMM were we using when we "saved" the inp file? |
src/consts.h
Outdated
#define VERSION 51011 //(5.1.011) | ||
// Update VERSION and SEMVERSION Simultaneously | ||
#define VERSION 51013 // Eventually will be deprecated. | ||
#define SEMVERSION "5.1.13.dev0" // Semantic Version |
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.
Actually I think it is more like
5.1.13dev0
We could store this as struct with major, minor, patch ?
struct VERSION_INFO {
char major[3];
char minor[3];
char patch[10];
};
Or something and generate VERSION and SEMVERSION from this with some helper funcs?
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.
@goanpeca good suggestion - yes I can do that. Maybe patch should be longer since perhaps we might be adding some git vers numbers to it.
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.
Sure, it can be, don't know how long though :-p
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.
@goanpeca, I think splitting these up into major minor and patch is good but I'm not sure that containing this into a struct
is necessary.
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.
I am happy to change the function to have three outputs:
int DLLEXPORT swmm_getSemVersion(char* major, char* minor, char* patch)
It leaves the user with more options.
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.
The more I think about it, I think simply outputting the char
array is the cleanest way.
Here's the scoop: You can now run:
Which gives:
|
Looks good :-) |
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.
Since you are in here you might as well go ahead and separate main()
from swmm5.c similar to what was done over in the EPANET repo. This way the dll and exe are two separate build targets and the exe can use the dll. Make sense?
src/swmm5.c
Outdated
{ | ||
strcpy(major, SEMVERSION_MAJOR); | ||
strcpy(minor, SEMVERSION_MINOR); | ||
strcpy(patch, SEMVERSION_PATCH); |
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.
Use secure string copy strcpy_s()
here instead.
src/swmm5.c
Outdated
strcat(semver, SEMVERSION_MINOR); | ||
strcat(semver, "."); | ||
strcat(semver, SEMVERSION_PATCH); | ||
} |
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 should be done in one line using a secure formatted print to string sprintf_s()
.
|
||
#define FMT03 " There are errors.\n" | ||
#define FMT04 " There are warnings.\n" | ||
#define FMT05 "\n" | ||
#define FMT06 "\n o Retrieving project data" | ||
#define FMT07 "\n o Writing output report" | ||
#define FMT08 \ | ||
"\n EPA STORM WATER MANAGEMENT MODEL - VERSION 5.1 (Build 5.1.012)" //(5.1.012) | ||
|
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.
Are we sure about all the places FMT08
is being used?
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.
I'm sure
Yes it makes sense 👍 ! |
@goanpeca I see it fitting in here, but I think @bemcdonnell wants to handle separating |
Sure, it also works! |
Update dynwave.c
No description provided.