Multi Project Setup

Hi,

I’m currently evaluating cocos2dx for a project that I’m working on. My experience has been in game console programming (ps3, xbox). This will be my first time doing mobile and I have little experience developing on a mac.

I’m trying to figure out the best way of creating a project tree with shared game code between Win32, Mac, iOS, and Android. The goal being shared game code and the ability to update cocos2dx to newer versions without rebuilding the projects.

I want a project tree like this:
* Project/
*** cocos2dx_base/
***** cocos2dx/
***** CocosDenshion/
***** extensions/
***** external/
*** game/
*** Classes/
*** proj.android/
*** proj.ios/
*** proj.mac/
*** proj.win32/
*** Resources/

I’ve managed to set this up quite easily for Win32 since all the libs have VC project files. All I had to do was create a new solution and game project and then add the lib projects I needed.

For iOS and Mac there are not any projects for the individual libs, except for cocos2dx.xcodeproj.

It seems the easiest way is to copied the TestCpp sample out and fixed up the paths, projects settings, etc… Similar to [[http://paralaxer.com/cocos2d-x-project-setup/]]. But that method is quite time consuming and doesn’t allow for easy updating of cocos2dx.

I hope that all made sense. Am I missing something? Is there an easier way of doing this?

Thanks.

I just came across this feature [[http://www.cocos2d-x.org/issues/1488]], which may be exactly what I was asking about. Can someone explain what the feature will consist of?

Thanks.

I advise to set up a project in VS (win32), iOS (XCode) and Eclipse and share the code (JUST the code) via Git.
I did this myself in our project.
Sadly you have to register newly added resources every time in the corresponding IDE.
So the typical work flow is as follows:
~~Create new project with cocos template in IDE.
~~Clone project form repo.
~~Copy project setup data in the cloned project and set them to git ignore list
~~Start the IDE and put all new data in the project (register them). (In VS simply click show files and add data it will auto sorted into the include and source workfloders)

And my advise for Windows is: Use VS2012 it’s much better than the old ones.

`Franky G,

Hi, did you manage to get this working? I started some tests with a similar approach. First I made a VS2010 project, then I created the android project and got this working using a similar folder setup as in the HelloCPP sample project. I got this working now in a way that i can develop in VS 2010, build and run the win32 project and also compile the android version. Now I want to use the same source files to build my IOS project, but i am stuck here at the moment. I am also new to OSX / Xcode and IOS development.

Would like to hear from you. If you still need any help on making the android project work with you VS2010 codebase, let me know and I will try to help you out.

Looking forward on your reply.

With kind regards,

Matthijs

ps.) `Daniel, thanks for the input, if I can not get this working the way I want I will try your approach:)

Hi folks,

Franky G wrote:

I’m trying to figure out the best way of creating a project tree with shared game code between Win32, Mac, iOS, and Android. The goal being shared game code and the ability to update cocos2dx to newer versions without rebuilding the projects.

I’ve been looking for something similar that decouples the actual code base from the library and project template trees. I’m using Cocos2d-X to teach cross-platform mobile game development, and the Android toolchain is incredibly brittle (possibly by Google’s design to discourage use of the JNI, but still…).

I have extensive experience in cross-platform desktop development using CMake, and it should be possible to come up with a bunch of CMakeLists to automatically generate IDE projects without having to rely on predefined, version-dependent templates. Maybe it’s worth a shot, but it’ll be a major undertaking and will require quite a bit of restructuring of the original code base, so I’d like to get a feel for how many people would be interested in that and how the project maintainers think about it.

Jens

I read a little bit about CMake and I don’t think that it is good for cross platform developing in our particular case.
I have no experience with CMake so I just write what i guess why it wouldn’t help us.

First of all you have to consider that some of our needed IDEs (thinking about Xcode/VS) are exlusivly running on different OS, which means we don’t benefit from compiling both once a time which seems to be one benefit of CMake (Am I right with this suggestion?).
Furthermore our Platforms are much more different than they would be if we just would have Unix Systems on the one and Win Systems on the other hand (for which CMake mostly seems to be made for (again I’m not sure if this is true)).
We not only have very different OS we also have much different hardware with a range from your XBox over your PC to your Smartphone, which needed to be treated very individually. Furthermore you are not working in the “normal” working chain of your target system (which is especially important because you can test one platform on the same device you are developing (PC) while another needs to be emulated and/or remotely debugged (Smartphone). Also Xcode doesn’t seem to be listed under the native build tools supported by CMake.

So instead of working with CMake i again suggest to just open default cocos2d-x projects in your target systems IDE (using the cocos2d-x templates) and adding your special code and even special folder structure via (for example) git. In this way you have the benefits of being in the default production chain of your targets system while sharing the same code easily and remotely over different systems any time everywhere even with team support. On the down side it means a bit more fiddling with your IDEs.

Are my critics justified or did i just don’t get how CMake works?

@Matthijs

I got it working using the folder structure from my first post for Win32, iOS, and Mac. Haven’t tried Android yet. I started with the TestCPP project.

Win32 was easy, just created solution and included project files for libs I needed and then renamed TestCPP project to “Game”.

Mac and iOS was a bit trickier. I opened TestCpp xcode project and started by fixing paths to cocos2dx project and other folders. Then renamed main project, plist, and pch files. Then I had to fix up paths in project settings for libs and headers. It would of been much easier if there was project files for the other cocos2dx libs.

Daniel Reichert wrote:

First of all you have to consider that some of our needed IDEs (thinking about Xcode/VS) are exlusivly running on different OS, which means we don’t benefit from compiling both once a time which seems to be one benefit of CMake (Am I right with this suggestion?).

That’s the whole point of CMake, that you describe the logical structure of a software project, including all its dependencies, independent of the source and target OS and have it generate IDE projects available on the source platform. E.g. on Windows, you can choose VS, Eclipse, regular Makefiles, etc, while on MacOS, you could use Xcode, Eclipse, Makefiles, Code::Blocks, etc, while on Linux, you could use Eclipse, Code::Blocks, Makefiles, etc. Some IDEs such as NetBeans or Qt Creator even support CMake natively. I agree that for deploying to mobile platforms, you are restricted to whatever deployment toolchain you have, which restricts us to Xcode on MacOS for iOS and Eclipse on Linux/MacOS/cygwin for Android, but given that all of these combinations are supported by CMake out of the box for native compilation and that CMake can easily handle cross-compilation, it should be possible to get CMake working and handle the code infrastructure in a platform-agnostic way.

Furthermore our Platforms are much more different than they would be if we just would have Unix Systems on the one and Win Systems on the other hand (for which CMake mostly seems to be made for (again I’m not sure if this is true)).

The build and deployment toolchains for all deployment targets supported by cocos2d-x are also restricted (if you can call it that) to Unix (including Linux and OSX) and Windows systems. CMake runs on these same systems.

We not only have very different OS we also have much different hardware with a range from your XBox over your PC to your Smartphone, which needed to be treated very individually.

Not from a userland code perspective, otherwise cocos2d-x wouldn’t make any sense as a project. The hardware differences should be (and of course are) handled by the cross-compiler and any libraries (e.g. cocos2d-x) that abstract away the hardware. If you write standards-compliant C++ code, you should not have to deal with hardware differences unless you specifically call platform-specific APIs. If any cocos2d-x project is tied to a specific target from the start, I might as well just use that target’s native toolchain.

Furthermore you are not working in the “normal” working chain of your target system (which is especially important because you can test one platform on the same device you are developing (PC) while another needs to be emulated and/or remotely debugged (Smartphone).

Define “normal”. I don’t consider cross-compilation abnormal. And, as you said, you can easily test on emulators, which is why they exist for both iOS and Android development, although ultimately you must deploy and test on the actual hardware, anyway. I don’t see how that impacts a build system.

Also Xcode doesn’t seem to be listed under the native build tools supported by CMake.

Run on my MacBook Pro:

localhost:~ jh$ cmake —help
cmake version 2.8.9
The following generators are available on this platform:
Ninja = Generates build.ninja files (experimental).
Unix Makefiles = Generates standard UNIX makefiles.
Xcode = Generate Xcode project files.
CodeBlocks - Ninja = Generates CodeBlocks project files.
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Unix Makefiles
= Generates Eclipse CDT 4.0 project files.
KDevelop3 = Generates KDevelop 3 project files.
KDevelop3 - Unix Makefiles = Generates KDevelop 3 project files.

So instead of working with CMake i again suggest to just open default cocos2d-x projects in your target systems IDE (using the cocos2d-x templates) and adding your special code and even special folder structure via (for example) git. In this way you have the benefits of being in the default production chain of your targets system while sharing the same code easily and remotely over different systems any time everywhere even with team support. On the down side it means a bit more fiddling with your IDEs.

I consider “fiddling with your IDEs” a huge downside, if I simultaneously want to deploy the same code base on both Android and iOS. I really resent the notion that I’d have to check in IDE-specific files into my code repository, and that I’d have to manually add files to, say, Xcode for iOS deployment and tweak Android.mk for Android deployment. I want my students to be able to concentrate on the game design issues and not having to know the ins and outs of any potential target platform. At the same time, I want to be able to deploy on multiple platforms simultaneously, which is the whole point of a cross-platform framework to begin with, otherwise I could just stick with the native frameworks.

Are my critics justified or did i just don’t get how CMake works?

Think of CMake as a build and configuration system, not necessarily as an IDE project generator. The restriction to certain IDEs in the case of cocos2d-x stems from the limitations of the target platforms and the choices the people in charge of those platforms made.

HTH,

Jens

Hi All,
I was writing a long message few minutes ago then i found this thread.
Its not so urgent than making hot fixes, but having a clean multi project build system is more than suited. CMake is a good alternative, and it’s not forbidden to put whatever script on top to generated the suited project file on top of it.