-
Notifications
You must be signed in to change notification settings - Fork 12
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
[*] repository merging #11
Conversation
…oprog/orcania/tree/cmake ; it replaces the old pure make to the platform CMake building; some fixes in the sources to compile on mingw-w64 32/64; add GCC/CLang's -Wextra flag; allow to control the library version from building system; allow to get library info from pkg-config tool in all supported platforms; export all Orcania API functions to be used by other programming languages; allow to include the Orcania header in C++ projects; and more other improvements.
Sorry, there's way too much changes in the pull request for me to accept this in my branch, the |
Makefile
Outdated
@@ -1,38 +0,0 @@ | |||
# |
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.
Don't remove the original Makefile
, it's still working to me
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 just removed them because your comment hehe: "... I don't know if I will keep both build systems (Makefile and CMake) or just keep CMake eventually but we're not there yet". But I'm going to restore them in next PR ...
cmake-modules/FindCheck.cmake
Outdated
@@ -0,0 +1,60 @@ | |||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
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.
What is this file for?
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 you help me with it? I used it inspired by cmake articles, but I'm not sure which license we need to adopt (I'm a little bit newbie with licensing, so they still confused for me 😅 ). Please feel free to change it to accomplish Orcania's licensing.
/** | ||
* Return the library version. | ||
*/ | ||
O_EXTERN const char *o_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.
What is it for?
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.
It is very, very required to export the API functions to other compilers (Pascal, Python, C# etc.). I don't know how to reproduce a demo showing the relevance, but you can see it present in many popular libraries (mhd, curl, uv etc.). When I remove it, for example, I can't call Orcania's functions from Delphi compiler. Regarding o_version()
, it is useful for who wants to show the dependencies version just calling a function that returns a string. You can see this function kind present in many libraries too.
/** | ||
* char * str_replace(const char * source, char * old, char * new) | ||
* replace all occurences of old by new in the string source | ||
* return a char * with the new value | ||
* return NULL on error | ||
* returned value must be free'd after use | ||
*/ | ||
char * str_replace(const char * source, const char * str_old, const char * str_new); | ||
O_EXTERN char * str_replace(const char * source, const char * str_old, const char * str_new); |
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 don't like having the macro O_EXTERN
prefixing every function provided by Orcania, is there a reason to do this?
src/Makefile
Outdated
@@ -1,82 +0,0 @@ | |||
# |
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.
Again, not a good idea to remove it in my opinion
src/base64.c
Outdated
@@ -7,7 +7,7 @@ | |||
*/ | |||
|
|||
#include <string.h> | |||
#include "orcania.h" | |||
#include <orcania.h> |
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.
For the library source, I prefer keeping
#include <string.h>
It's more relevant like this to me
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.
Indeed. It was a typo. <some-api.h>
makes sense only in examples, e.g mhd/doc/examples/hellobrowser.c. I've used MHD to show some practices, but I've seen them in other libraries too. I'm going to remove <orcania.h>
from src
and keep it only in the examples/tests.
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 made a typo on this one, I meant to keep the include like this in the library source:
#include "orcania.h"
I don't know why it showed string.h
instead, sorry
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 for cleaning the changes. I'm going to compile and check it again 😅 ...
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.
Hey dude it was a typo. Fixed in https://github.com/silvioprog/orcania/commit/f4dfb2e179b7300240fb1cc0fd7c642514abaaf0 .
@@ -1,9 +1,11 @@ | |||
#define _GNU_SOURCE | |||
#ifndef _GNU_SOURCE | |||
# define _GNU_SOURCE |
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.
Why do you define _GNU_SOURCE
like this? I'm not sure I get 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.
To avoid conflict with the building when it already enabled this flags, please see: silvioprog/orcania/blob/cmake/CMakeLists.txt#L30.
src/orcania.c
Outdated
@@ -107,7 +116,7 @@ char * o_strdup(const char * source) { | |||
char * o_strndup(const char * source, size_t len) { | |||
char *new_str; | |||
|
|||
if (source == NULL || len < 0) { | |||
if (source == NULL || (int)len < 0) { |
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.
not necessary to cast len, a size_t
variable can be tested with 0
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 you compile it with -Wall -Werror -Wextra
?
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.
OK, compiling with -Wall -Werror -Wextra
tells me:
orcania.c:110:29: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
if (source == NULL || len < 0) {
Which means the comparison is not necessary at all, this line should be then:
if (source == NULL) {
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.
…ries, makefiles, temporary files etc allowing to revert deleted makefiles listed at #10 (comment) .
I've made some changes applying requested fixes. Could you try the old building system again? |
Hello @silvioprog , Based on your script files, I've made a new branch in Orcania to build it with CMake. It only does the CMake part though. That's much more how I see it should be for now. Thanks |
Hello dude! 😎 Well, if somebody wants to compile Orcania (or any project that use it as dependence) on Windows [mingw32/64], they need to apply these two additional fixes:
But I think I'll leave it as it is. Unfortunately I can't work only for Unix, because there are many Windows users that I need to support hehe, so I always need to work minding in cross platform. 😅 |
OK no problem, thanks for the job on porting Orcania to Windows with MinGW, I will reuse the same pattern for Yder and Ulfius, and hopefully Ulfius will be available on Windows soon 🥇 |
Awesome. And with the CMake building is very easy to auto downloading Orcania as dependence project to Yder (and Yder+Orcania to Ulfius too). 😄 |
apply many improvements from this brach: https://github.com/silvioprog/orcania/tree/cmake ; it replaces the old pure make to the platform CMake building; some fixes in the sources to compile on mingw-w64 32/64; add GCC/CLang's -Wextra flag; allow to control the library version from building system; allow to get library info from pkg-config tool in all supported platforms; export all Orcania API functions to be used by other programming languages; allow to include the Orcania header in C++ projects; and more other improvements.
it fixes #10 .