mas-bandwidth / yojimbo

A network library for client/server games written in C++
BSD 3-Clause "New" or "Revised" License
2.46k stars 239 forks source link

Cmake? #21

Closed fire closed 7 years ago

fire commented 7 years ago

Would you accept a cmake version of the build system? If I made one? Not sure how to deal with two versions of the build system though because one be outdated.

gafferongames commented 7 years ago

Thanks for the offer. What do you propose? Would the CMake just trail behind a bit? Are you volunteering to maintain the CMake build system on all platforms?

fire commented 7 years ago

Let me get a prototype cmake project running then and see.

I can maintain Cmake on Windows and maybe Linux. Not sure about iOS and Android or Mac.

fire commented 7 years ago

Here is an initial cmake for Windows. The various executables compile but secure_server didn't run.

Todo:

fire commented 7 years ago

Prefixed the executables with yojimbo because the test is a reserved project name.

gafferongames commented 7 years ago

No need to port:

Basically, I don't think it's necessary to port any of the "shortcuts" actions I've setup in premake to CMake. If you build a CMake version that just builds the libraries and test programs, and works on Windows, Linux, MacOSX that would be fine and I would accept that.

Also, that automatic build you mentioned for libsodium and mbedtls is a win for CMake vs. premake5, especially on Windows platform, and on more conservative Linux like Debian, where they aren't in any package manager.

cheers

gafferongames commented 7 years ago

Can you give more detail about secure_server? Why does it not run? It's important that works. Does secure_server run on your machine when you build it with premake instead?

fire commented 7 years ago

secure server started on port 40000 but I don't know how to secure connect.

fire commented 7 years ago

YOJIMBO_INSECURE_CONNECT does not compile when set to 0.

fire commented 7 years ago

Also I would like some sort of YOJIMBO_SECURE_CONNECT_ONLY that does not require me to force remove a definition.

For instance if I want to enable secure connections. All I want is to enable one flag.

add_executable(
  yojimbo_client
  yojimbo
  tests/client.cpp
  )

target_compile_definitions(  yojimbo_client PRIVATE SECURE_CLIENT=1)

target_link_libraries(
  yojimbo_client
  yojimbo
  )
gafferongames commented 7 years ago

Oh the secure connect is working fine. It's by design that the regular client cannot connect to the server, as it only allows secure connects through the matcher (eg. "premake5 matcher" followed by "premake5 connect").

cheers

gafferongames commented 7 years ago

I'm thinking about the YOJIMBO_SECURE_CONNECT_ONLY idea, it seems reasonable.

gafferongames commented 7 years ago

Replaced YOJIMBO_ALLOW_INSECURE_CONNECT with YOJIMBO_SECURE_MODE, and fixed the compile errors. I called it "secure mode" because I might hang other things off this define in future (eg. proper cert check for matcher), and I want yojimbo to be secure by default when YOJIMBO_SECURE_MODE 1 is true. https://github.com/networkprotocol/libyojimbo/commit/7e79844cfc229f054fdf7ee12263f3218fc281f3

fire commented 7 years ago

Looks good. However the yojimbo secure client doesn't automatically connect to the server anymore. Not sure the details, but the code is empty.

gafferongames commented 7 years ago

"connect.cpp" was moved to "secure_client.cpp" so it's more obvious how to secure connect a client. Just rename the "connect" project to "secure_client" and build "secure_client.cpp" instead of "connect.cpp".

I also split apart "secure_server.cpp" from "server.cpp", because that code was getting hard to read, and it's more consistent. eg. client -> server, secure_client -> secure_server. You don't need to do the #define SECURE_SERVER 1 dance on server.cpp anymore, just build secure_server.cpp

Also, check out the latest premake5.lua in last commit, I added "Debug_Secure" and "Release_Secure" build configurations that #define YOJIMBO_SECURE_MODE 1 and added these configurations to the travis automatic build and test. This should make sure that secure mode stays compile error free (I don't usually build and test during development with secure mode enabled, so as I make unrelated changes, compile errors would creep in).

cheers

gafferongames commented 7 years ago

I'm closing this issue as it seems you should be unblocked. Let me know when you have a pull request with the CMake config that works with mbedtls and libsodium built through hunter. I'm happy to review it.

cheers

fire commented 7 years ago

I found some time to work on this.

fire commented 7 years ago

The cmake project now have sodium integrated with hunter. Just waiting on the other package.

gafferongames commented 7 years ago

Thanks!