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

V3 android cmake support #18154

Closed
wants to merge 27 commits into from
Closed

Conversation

newnon
Copy link
Contributor

@newnon newnon commented Aug 11, 2017

CMake build improvements & android CMake support
add to graddle.properties
PROP_NDK_MODE=cmake
replace files in folder external/android-specific
android-specific.zip

last PR #17100

pull request for external
cocos2d/cocos2d-x-3rd-party-libs-bin#300

@minggo
Copy link
Contributor

minggo commented Aug 22, 2017

Looks good, so i have to merge cocos2d/cocos2d-x-3rd-party-libs-bin#300 to test it right? Could you please show me the steps to use cmake in gradle, thanks?

@newnon
Copy link
Contributor Author

newnon commented Aug 22, 2017

  1. ensure that you have installed NDK & CMake from android studio package manager
  2. update externals(just few changes in android_specific folder)
  3. add to graddle.properties PROP_NDK_MODE=cmake(without it it will use ndkbuild)
  4. make clean build

@minggo
Copy link
Contributor

minggo commented Aug 23, 2017

thanks, i have CMake installed in system(Mac OS), should the CMake be installed from android studio package manger again?

And in which path should i run make clean build?

@newnon
Copy link
Contributor Author

newnon commented Aug 23, 2017

Yes you shod install it from package manager(it will be installed inside SDK folder) if google does not change this, android studio does not use system CMake.

@crazyhappygame
Copy link
Contributor

Guys,
When we may expect cmake to see in v3 branch?

@drelaptop
Copy link
Contributor

Sorry for a long response, I really appreciate this patch. @newnon

Following your steps, I have tested it using latest code, it occurred a path error ,and then I fixed it in this commit. finally cpp-tests and cpp-empty-test build works well both cmake build and ndkBuild.

Suggestion:

  1. to merge the latest code into your branch to solve conflicts
  2. fix path error, from proj.android/jni/main.cpp to proj.android/app/jni/main.cpp
  3. add PROP_NDK_MODE=cmake to gradle.properties for all proj.android, and do some comments in detail.
    comments like:
# android cmake support
# uncomment it, native code will build by cmake
# keep comment, native code will build by ndkBuild
#PROP_NDK_MODE=cmake
  1. do further test, and tell what done and what undone, we should test in detail as possible as we can before merge. I will do it with you.

@drelaptop
Copy link
Contributor

drelaptop commented Jan 3, 2018

@crazyhappygame cmake support android will be done in 3.17, this is I wish.

support other platforms is on schedule, but I couldn't give you the deadline, we can do it together to make it done earlier.

@newnon
Copy link
Contributor Author

newnon commented Jan 3, 2018

OK I will try to do it as soon as possible.

@drelaptop
Copy link
Contributor

CMake support for js-tests android project occurred errors, when I try to run js-tests using CMake build, please have a test after you adding cmake config to js-tests, and try to fix this.

you know we have to make sure all android project support cmake well, the tests project, the template project, even the lib project. really a lot of work to do for us.

@crazyhappygame
Copy link
Contributor

@newnon would it be possible with cmake to build cocos2d-x once and use build output libraries in other games? I would like to save compilation time for my android games.

@drelaptop
Copy link
Contributor

Any progress about cmake ? @newnon

You can have a try to use the output libraries in your game, hope for your feedback @crazyhappygame

@newnon
Copy link
Contributor Author

newnon commented Jan 8, 2018

@drelaptop cleared version rebased on top of current v3

@newnon
Copy link
Contributor Author

newnon commented Jan 8, 2018

@crazyhappygame unfortunately i haven't try this options, but it is possible.

Copy link
Contributor

@drelaptop drelaptop left a comment

Choose a reason for hiding this comment

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

when change the cmake files of Android, I suggest keep other platform logic same. If not, do test to confirm the logic right.

elseif(MACOSX)
set(COCOS_NETWORK_PLATFORM_SRC
network/CCDownloader-apple.mm
)
Copy link
Contributor

@drelaptop drelaptop Jan 9, 2018

Choose a reason for hiding this comment

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

error occur when you delete this line, compile error on mac:

[ 82%] Linking CXX executable ../../bin/cpp_tests.app/Contents/MacOS/cpp_tests
Undefined symbols for architecture x86_64:
  "cocos2d::network::DownloaderApple::DownloaderApple(cocos2d::network::DownloaderHints const&)", referenced from:
      cocos2d::network::Downloader::Downloader(cocos2d::network::DownloaderHints const&) in libcocos2dInternal.a(CCDownloader.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

you can merge this to fix newnon#5

@drelaptop
Copy link
Contributor

drelaptop commented Jan 9, 2018

This commit fix js-tests build error on mac, and build success, but run failed, only a black box appear. please help to do some check if you have free time.

#18545 have been fixed too, run failed is strange, please give some instructions about black box if you have time recently. @dumganhar

V3 merge android cmake, fix error for network module
@drelaptop
Copy link
Contributor

drelaptop commented Jan 9, 2018

Sorry, some config difference exist on js-tests, build right and run success, App path is different from others, see bin files tree:

├── cpp_empty_test.app
│   └── Contents
├── cpp_tests.app
│   └── Contents
├── js-tests
│   ├── js-tests
│   ├── main.js
│   ├── project.json
│   ├── res
│   ├── script
│   └── src
├── lua-tests.app
│   └── Contents
└── lua_empty_test.app
    └── Contents

bin/js-tests/js-tests is the js-tests project App, which is different from cpp-tests.app

Now, this branch on macOS(not include iOS) platform, cocos2d-x cmake build success, all tests project run success too. cmake .. -G ”Xcode“ generate Xcode macOS project success, tests project except js-tests run in Xcode well.

js-tests project run in Xcode need to be look into
project by cocos new need to be test

@drelaptop
Copy link
Contributor

#18646 have been merged, this PR can be closed directly, thank you @newnon

@minggo minggo closed this Feb 8, 2018
@minggo
Copy link
Contributor

minggo commented Feb 8, 2018

@drelaptop please write a doc for it and ask developers to test it. Thanks.

@drelaptop
Copy link
Contributor

yeah, I should do that, a sample guide have been added in the http://discuss.cocos2d-x.org/t/in-progress-cmake-support-all-platform-for-cocos2d-x/41164/13

I will add cmake android guide later

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.

None yet

4 participants