-
Notifications
You must be signed in to change notification settings - Fork 204
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
cmark-gfm: add #719
cmark-gfm: add #719
Conversation
Because CMake is so amazingly wonderful, it generates a statically coded boilerplate file that really is trivial to check into git. It's pretty annoying that projects rely on a weird CMake function instead. But the really bad part of this is that CMake generates a different file depending on your OS. This should just include support for all OSes via compiler check macros. Basically:
The CMake generated file just ritualizes this with project-specified scope names, including a bit of gunk nobody actually uses in their CMake projects. |
I agree that the CMake export functionality is extremely annoying. If we restrict this wrap to solely build cmark-gfm as a static library then we can drastically simplify the export files but ignoring all of the visibility
That would then get written to the Does this sound reasonable? |
That's just random goop which CMake creates, and cmark-gfm doesn't use. Anyway, I went and ported cmark to use a simpler header that Meson can use too. It would need to be merged into cmark, then merged again into cmark-gfm, then released, before this wrap could take advantage of it... but this wrap could still include the header itself in the meantime. |
Here's a much better template to use.
I also removed the pointless duplication of headers... but that needs patches to cmark-gfm. |
Nice, thanks for making the PR upstream. Let me know if there is anything I can do to help. In the meantime I suppose we will let this PR sit on ice until upstream gets fixed, unless you have a better idea... Including the headers will cause the PR to fail tests unfortunately so that's not an option, unless we want to special-case it. |
Simply name the headers |
subprojects/packagefiles/cmark-gfm/cmark-gfm-extensions_export.h.meson
Outdated
Show resolved
Hide resolved
These commits should all be squashed into one commit, probably... |
@eli-schwartz thanks, I implemented your suggestion. Commits are all squashed and the wrap builds and passes sanity check locally. I think the remaining items are to run CI on this to ensure it's clean, and then merge if everyone find it satisfactory. |
Looks like I made a mistake when I formatted the file, one moment while I fix it... |
Should be good to go now. |
|
Saw that, fixing it now. |
@neheb fixed, though only for compilers that support |
@@ -94,7 +94,10 @@ src = files( | |||
) | |||
|
|||
# Many unused parameters warnings when this warning is enabled. | |||
add_project_arguments('-Wno-unused-parameter', language: 'c') | |||
cc = meson.get_compiler('c') | |||
if (cc.has_argument('-Wno-unused-parameter')) |
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.
if (expression)
is equivalent to if (expression)
, the grouping isn't doing anything here.
Also note there is:
add_project_arguments(cc.get_supported_arguments('-Wno-unused-parameter'), language: 'c')
which means you don't need to repeat the argument name.
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.
Thanks, the extra brackets were an honest mistake. Incorporated your feedback on the latest commit.
since there's dllexport functionality now, probably makes sense to use library() instead of static_library(). |
edata = configuration_data( | ||
{ | ||
'CMARK_GFM_STATIC_DEFINE': true, | ||
}, | ||
) |
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 assumes that we use static_library() down below, but I think we can safely use library()
instead. It's possible to change this with default_options: ['default_library=static']
either in the project()
function or when invoking dependency()
from a parent project. In both cases, the user still has the ability to manually override that on the command line if they really want.
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.
Is there a way to check if the library is being built as a static library or a dynamic library? The reason I ask is because we have the section below hardcoded, but this should be dynamic depending on if the user wants it built statically or dynamically.
edata = configuration_data(
{
'CMARK_GFM_STATIC_DEFINE': true,
},
)
If we want to use library()
instead of static_library()
, we'll have to set cdata.CMARK_GFM_STATIC_DEFINE
at configure-time and I don't know to get that information needed to make that decision. Any pointers are appreciated.
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.
Never mind, I figured it out. Fixing it now.
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.
Could be rebased again. :)
Rebased it and incorporated all feedback so far. |
On MSVC:
Apparently a compile test is NOT good enough for that one. :) Makes sense in retrospect, it's not syntactically wrong. |
Thoughts on these Windows linker warnings? |
This should be squashed. As far as the file, you could probably avoid all that mess by manipulating cpp_args. See my recent PRs doing just that. |
You cannot manipulate cpp_args in order to solve the issue of the upstream main header attempts to Also in general command line length bloat can cause bugs where e.g. Windows just errors out because too long, but sometimes it is regrettably unavoidable... |
Sure you can. Just empty it out. That's what I did for libebml. |
Why painfully bend over backwards to install an empty file, when if you are just going to hardcode a list of static defines you can just dump them as a set of configuration_data() values into the exact same configure_file()? EDIT: can we please revert the libebml thing? It looks really awkward and painful. |
I’d rather not. Note that it’s dllexport when building the library and dllimport when using it. edit: do note it's also a bugfix for having one library (both actually) being forced to be built as static. |
I've squashed the series of commits just now. I would also prefer to use the same semantics as upstream does by generating the full I believe the last outstanding issue is the Windows linker warnings. I do not have a Windows machine to test with (other than CI), so I would appreciate any help (a patch is especially welcome) in solving that issue. Thank you. Edit: I just re-reviewed the code and I believe the latest commit should fix the Windows linker issues. Waiting for a CI build to confirm. |
Linker warnings on Windows are fixed. I'm squashing the PR and I think it is ready to be merged in now barring any final review comments. |
Issues seem to be fixed and tests are green so merging. Further minor issues can be fixed in subsequent MRs. |
Yup, agreed. |
Thank you for merging this PR in, and thank you @eli-schwartz and @neheb for your help in getting it ready to merge 🙂 |
Per @eli-schwartz's suggestion in hdoc/hdoc#25, we'd like to contribute a Meson wrap for the cmark-gfm package.
This is a C library that implements parsing of Markdown files, and includes some extensions that GitHub (the company) has made. It's built using CMake, and this PR adds Meson support as a wrap.