fungos / cr

cr.h: A Simple C Hot Reload Header-only Library
https://fungos.github.io/cr-simple-c-hot-reload/
MIT License
1.55k stars 104 forks source link

Add macOS support #1

Closed fungos closed 5 years ago

fungos commented 6 years ago

A missing wanted feature is support to macOS, at the current moment I don't have access to a Mac, but will try to get this done one way or another.

denji commented 6 years ago

https://docs.travis-ci.com/user/reference/osx/

pamarcos commented 6 years ago

I have inspected briefly the code and I think porting to macOS should be pretty easy. It's a matter of replacing the ELF-related stuff with Mach-O. I have actually tried to compile this for macOS but got the following error when running python fips build:

fips-googletest/gtest/include/gtest/internal/gtest-port.h:495:13: fatal error: 'tr1/tuple' file not found
#   include <tr1/tuple>
            ^~~~~~~~~~~
1 error generated.

Doing a quick search it seems that's something fixed in GTest quite some time ago to support newer compilers. This is my current compiler in macOS High Sierra 10.13.1:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin17.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I can still try to build everything else, but wanted to let you know that you may need to update the sources for GTest at https://github.com/fungos/fips-googletest to support macOS

denji commented 6 years ago

https://github.com/fungos/fips-googletest/blob/03ae580/gtest/include/gtest/internal/gtest-port.h#L432-L500

libc++ has no support for tr1, since that is not part of the C++11 standard. All of std::tr1 (with the exception of some esoteric math functions), is now just in “std::”

pamarcos commented 6 years ago

Yes, my understanding is that in order to use tuple before it was standardized in C++11 you needed to use the tr prefix, in a similar way that you need to use experimental for filesystem now. The issue is that the GTest header used in https://github.com/fungos/fips-googletest is quite old and prior to the point where typle was already in std

denji commented 6 years ago

GTest header used in https://github.com/fungos/fips-googletest is quite old and prior to the point where typle was already in std

Yes they are quite old they do not contain instructions for LLVM/Clang compatibility (only MSC & GCC).

fungos commented 6 years ago

I don't expect it being harder than a couple of hours, as it you've pointed it being more a question of Mach-O and maybe some issue with the signal handling.

I'll take a look at upgrading fips-googletest then, thanks for the early research to both of you.

A next step will be to ifdef-out linux specific things (mostly the state transfer stuff) and try to get it at least compiling on travis osx.

UPDATE: fips-googletest is up-to-date, it should work now. You should delete your local one, then when generating the cr solution it should fetch the new one.

seanpaultaylor commented 6 years ago

Would love to also have MacOS support!