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

[*] repository merging #11

Closed
wants to merge 10 commits into from
Closed

[*] repository merging #11

wants to merge 10 commits into from

Conversation

silvioprog
Copy link
Contributor

@silvioprog silvioprog commented Jan 20, 2018

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 .

…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.
@babelouest
Copy link
Owner

Sorry, there's way too much changes in the pull request for me to accept this in my branch, the CMake script should be in addition to the original Makefile, not replacing it. And I don't think the .h files should have that much change either.
I'll make some reviews to the pull request, we can discuss it there if you want.

Makefile Outdated
@@ -1,38 +0,0 @@
#
Copy link
Owner

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

Copy link
Contributor Author

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 ...

@@ -0,0 +1,60 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
Copy link
Owner

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?

Copy link
Contributor Author

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();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is it for?

Copy link
Contributor Author

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);
Copy link
Owner

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 @@
#
Copy link
Owner

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>
Copy link
Owner

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

Copy link
Contributor Author

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.

Copy link
Owner

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

Copy link
Contributor Author

@silvioprog silvioprog Jan 21, 2018

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 😅 ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1,9 +1,11 @@
#define _GNU_SOURCE
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
Copy link
Owner

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.

Copy link
Contributor Author

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) {
Copy link
Owner

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

Copy link
Contributor Author

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?

Copy link
Owner

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) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@silvioprog
Copy link
Contributor Author

I've made some changes applying requested fixes. Could you try the old building system again?

@babelouest
Copy link
Owner

Hello @silvioprog ,

Based on your script files, I've made a new branch in Orcania to build it with CMake.
https://github.com/babelouest/orcania/tree/cmake

It only does the CMake part though. That's much more how I see it should be for now.
This branch works on my linux devices, but can you test it in your environments and send me your feedbacks?

Thanks

@silvioprog silvioprog closed this Jan 21, 2018
@silvioprog
Copy link
Contributor Author

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. 😅

@babelouest
Copy link
Owner

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 🥇

@silvioprog
Copy link
Contributor Author

silvioprog commented Jan 22, 2018

Awesome. And with the CMake building is very easy to auto downloading Orcania as dependence project to Yder (and Yder+Orcania to Ulfius too). 😄

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

Successfully merging this pull request may close these issues.

Build Orcania with CMake
2 participants