Skip to content

Commit

Permalink
mac support added.
Browse files Browse the repository at this point in the history
  • Loading branch information
robochase6000 committed Jul 9, 2014
1 parent eea6681 commit ef57e00
Show file tree
Hide file tree
Showing 61 changed files with 7,615 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
obj
haxe
.DS_Store
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Some familiarity with ENet might help.
With these wrappers, you should be able to release online multiplayer games for Haxe's C++ target.
I wrote this with HaxeFlixel in mind, but you should be able to use just about any other game engine that supports the C++ target.

## Instructions:
## PC Instructions:

* To use this in your project, grab the /source/enet directory and put that in your source directory.
* Also, copy the .ndll from my /export/cpp/windows/bin directory to the directory containing your executable. (32-bit ndll)
Expand All @@ -20,5 +20,17 @@ This is my first adventure in C/C++, so that part of the code might not be stell

The .ndll provided has been compiled for Windows. I honestly don't know how to provide support for Linux and Mac, sorry. If someone could help for that it would be great.

## Mac Instructions

Mac support is a bit weak right now, but it's coming together.

* when you compile your executable via "lime test mac", you'll want to navigate to the .app file that is generated and make sure you copy c_source_mac/bin/Debug/EnetTesting.dylib into the .app file.
* copy c_source_mac/bin/Debug/EnetTesting.dylib and paste it into export/mac64/cpp/bin/ENETWRAP.app/Contents (remember you can right click ENETWRAP.app and select Show Package Contents to browse the .app's contents!). There's probably a way to ensure the dylib is compiled into the .app by lime or haxe, but my knowledge of this process is currently pretty limited.
* if for whatever reason your mac architecture is not x86-64, you'll probably need to recompile EnetTesting.dylib. In the c_source_mac folder, you'll find a Codeblocks project file (EnetTesting.cbp) which you can use to recompile the EnetTesting.dylib. You'll probably need to recompile the enet library for you current system setup, and replace the compiled enet dylib found at c_source_mac/libraries/libenet.dylib.

Note that

## TODO:
* Linux + Mac + Android + iOS? ndlls
* Linux + Android + iOS? ndlls
* Better Mac support - on the c++ side of this, certain features have been turned off in c_source_mac/main.cpp because it was originally dependent on some Windows-only libraries. Someone in the know should make a pass at this file and replace the windows-only functionality with something that is cross-platform. the bulk of the problematic code is in the function enet_get_printable_ip
* would be rad if the client/server output were printed to the screen and not just traced to the command line. this will make testing on mobile devices a bit easier, and it will also not appear to fail silently if you forget to add the -debug flag when compiling.
49 changes: 49 additions & 0 deletions c_source_mac/EnetTesting.cbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="EnetTesting" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/EnetTesting" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="3" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
<Add option="-m32" />
<Add directory="includes" />
</Compiler>
<ResourceCompiler>
<Add directory="../archive" />
</ResourceCompiler>
<Linker>
<Add option="-arch x86_64" />
<Add library="libraries/libenet.dylib" />
<Add directory="../archive" />
</Linker>
</Target>
<Target title="Release">
<Option output="bin/Release/EnetTesting" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="3" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="main.cpp" />
<Extensions>
<code_completion />
<envvars />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>
209 changes: 209 additions & 0 deletions c_source_mac/EnetTesting.depend
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
# depslib dependency file v1.0
1396126460 source:c:\users\ohmnivore\desktop\cppdev\enettesting\main.cpp
<stdio.h>
<stdlib.h>
<conio.h>
<enet/enet.h>
<stdlib.h>
<string>
<sstream>
<hx/CFFI.h>

1388069580 c:\users\ohmnivore\desktop\cppdev\enettesting\includes\enet\enet.h
<stdlib.h>
"enet/win32.h"
"enet/unix.h"
"enet/types.h"
"enet/protocol.h"
"enet/list.h"
"enet/callbacks.h"

1388069580 c:\users\ohmnivore\desktop\cppdev\enettesting\includes\enet\win32.h
<stdlib.h>
<winsock2.h>

1388069580 c:\users\ohmnivore\desktop\cppdev\enettesting\includes\enet\unix.h
<stdlib.h>
<sys/time.h>
<sys/types.h>
<sys/socket.h>
<netinet/in.h>
<unistd.h>

1388069580 c:\users\ohmnivore\desktop\cppdev\enettesting\includes\enet\types.h

1388069580 c:\users\ohmnivore\desktop\cppdev\enettesting\includes\enet\protocol.h
"enet/types.h"

1388069580 c:\users\ohmnivore\desktop\cppdev\enettesting\includes\enet\list.h
<stdlib.h>

1388069580 c:\users\ohmnivore\desktop\cppdev\enettesting\includes\enet\callbacks.h
<stdlib.h>

1388700673 c:\users\ohmnivore\desktop\cppdev\enettesting\includes\hx\cffi.h
"OS.h"
<stdio.h>
<stdlib.h>
"CFFILoader.h"
"CFFIAPI.h"

1388700673 c:\users\ohmnivore\desktop\cppdev\enettesting\includes\hx\os.h
<stddef.h>
<stdint.h>
<errno.h>

1388700673 c:\users\ohmnivore\desktop\cppdev\enettesting\includes\hx\cffiloader.h
<android/log.h>
<windows.h>
<stdio.h>
<mach-o/dyld.h>
<dlfcn.h>
<stdio.h>
<stdlib.h>
<memory.h>
<hx/NekoFunc.h>

1388700673 c:\users\ohmnivore\desktop\cppdev\enettesting\includes\hx\nekofunc.h

1388700673 c:\users\ohmnivore\desktop\cppdev\enettesting\includes\hx\cffiapi.h

1397330923 source:c:\users\ohmnivore\desktop\haxedev\enetwrap\c_source\main.cpp
<stdio.h>
<stdlib.h>
<conio.h>
<enet/enet.h>
<stdlib.h>
<string>
<sstream>
<map>
<hx/CFFI.h>

1388069580 c:\users\ohmnivore\desktop\haxedev\enetwrap\c_source\includes\enet\enet.h
<stdlib.h>
"enet/win32.h"
"enet/unix.h"
"enet/types.h"
"enet/protocol.h"
"enet/list.h"
"enet/callbacks.h"

1388069580 c:\users\ohmnivore\desktop\haxedev\enetwrap\c_source\includes\enet\win32.h
<stdlib.h>
<winsock2.h>

1388069580 c:\users\ohmnivore\desktop\haxedev\enetwrap\c_source\includes\enet\unix.h
<stdlib.h>
<sys/time.h>
<sys/types.h>
<sys/socket.h>
<netinet/in.h>
<unistd.h>

1388069580 c:\users\ohmnivore\desktop\haxedev\enetwrap\c_source\includes\enet\types.h

1388069580 c:\users\ohmnivore\desktop\haxedev\enetwrap\c_source\includes\enet\protocol.h
"enet/types.h"

1388069580 c:\users\ohmnivore\desktop\haxedev\enetwrap\c_source\includes\enet\list.h
<stdlib.h>

1388069580 c:\users\ohmnivore\desktop\haxedev\enetwrap\c_source\includes\enet\callbacks.h
<stdlib.h>

1388700673 c:\users\ohmnivore\desktop\haxedev\enetwrap\c_source\includes\hx\cffi.h
"OS.h"
<stdio.h>
<stdlib.h>
"CFFILoader.h"
"CFFIAPI.h"

1388700673 c:\users\ohmnivore\desktop\haxedev\enetwrap\c_source\includes\hx\os.h
<stddef.h>
<stdint.h>
<errno.h>

1388700673 c:\users\ohmnivore\desktop\haxedev\enetwrap\c_source\includes\hx\cffiloader.h
<android/log.h>
<windows.h>
<stdio.h>
<mach-o/dyld.h>
<dlfcn.h>
<stdio.h>
<stdlib.h>
<memory.h>
<hx/NekoFunc.h>

1388700673 c:\users\ohmnivore\desktop\haxedev\enetwrap\c_source\includes\hx\nekofunc.h

1388700673 c:\users\ohmnivore\desktop\haxedev\enetwrap\c_source\includes\hx\cffiapi.h

1404881504 source:/Users/chasedelanguillette/Documents/development/haxe/projects/HaxeNet/c_source_mac/main.cpp
<stdio.h>
<stdlib.h>
<enet/enet.h>
<stdlib.h>
<string>
<sstream>
<map>
<hx/CFFI.h>

1404880632 /Users/chasedelanguillette/Documents/development/haxe/projects/HaxeNet/c_source_mac/includes/enet/enet.h
<stdlib.h>
"enet/win32.h"
"enet/unix.h"
"enet/types.h"
"enet/protocol.h"
"enet/list.h"
"enet/callbacks.h"

1404880632 /Users/chasedelanguillette/Documents/development/haxe/projects/HaxeNet/c_source_mac/includes/enet/win32.h
<stdlib.h>
<winsock2.h>

1404880632 /Users/chasedelanguillette/Documents/development/haxe/projects/HaxeNet/c_source_mac/includes/enet/unix.h
<stdlib.h>
<sys/time.h>
<sys/types.h>
<sys/socket.h>
<netinet/in.h>
<unistd.h>

1404880632 /Users/chasedelanguillette/Documents/development/haxe/projects/HaxeNet/c_source_mac/includes/enet/types.h

1404880632 /Users/chasedelanguillette/Documents/development/haxe/projects/HaxeNet/c_source_mac/includes/enet/protocol.h
"enet/types.h"

1404880632 /Users/chasedelanguillette/Documents/development/haxe/projects/HaxeNet/c_source_mac/includes/enet/list.h
<stdlib.h>

1404880632 /Users/chasedelanguillette/Documents/development/haxe/projects/HaxeNet/c_source_mac/includes/enet/callbacks.h
<stdlib.h>

1404880632 /Users/chasedelanguillette/Documents/development/haxe/projects/HaxeNet/c_source_mac/includes/hx/CFFI.h
"OS.h"
<stdio.h>
<stdlib.h>
"CFFILoader.h"
"CFFIAPI.h"

1404880632 /Users/chasedelanguillette/Documents/development/haxe/projects/HaxeNet/c_source_mac/includes/hx/OS.h
<stddef.h>
<stdint.h>
<errno.h>

1404880632 /Users/chasedelanguillette/Documents/development/haxe/projects/HaxeNet/c_source_mac/includes/hx/CFFILoader.h
<android/log.h>
<windows.h>
<stdio.h>
<mach-o/dyld.h>
<dlfcn.h>
<stdio.h>
<stdlib.h>
<memory.h>
<hx/NekoFunc.h>

1404880632 /Users/chasedelanguillette/Documents/development/haxe/projects/HaxeNet/c_source_mac/includes/hx/NekoFunc.h

1404880632 /Users/chasedelanguillette/Documents/development/haxe/projects/HaxeNet/c_source_mac/includes/hx/CFFIAPI.h

9 changes: 9 additions & 0 deletions c_source_mac/EnetTesting.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9496" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>
Binary file added c_source_mac/bin/Debug/EnetTesting.dylib
Binary file not shown.
27 changes: 27 additions & 0 deletions c_source_mac/includes/enet/callbacks.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
@file callbacks.h
@brief ENet callbacks
*/
#ifndef __ENET_CALLBACKS_H__
#define __ENET_CALLBACKS_H__

#include <stdlib.h>

typedef struct _ENetCallbacks
{
void * (ENET_CALLBACK * malloc) (size_t size);
void (ENET_CALLBACK * free) (void * memory);
void (ENET_CALLBACK * no_memory) (void);
} ENetCallbacks;

/** @defgroup callbacks ENet internal callbacks
@{
@ingroup private
*/
extern void * enet_malloc (size_t);
extern void enet_free (void *);

/** @} */

#endif /* __ENET_CALLBACKS_H__ */

Loading

0 comments on commit ef57e00

Please sign in to comment.