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

package.tools.cmake: Use newer Android toolchain and support runtimes #4917

Merged
merged 3 commits into from
Apr 1, 2024

Conversation

SirLynix
Copy link
Member

@SirLynix SirLynix commented Apr 1, 2024

  • Before adding new features and new modules, please go to issues to submit the relevant feature description first.
  • Write good commit messages and use the same coding conventions as the rest of the project.
  • Please commit code to dev branch and we will merge into master branch in feature
  • Ensure your edited codes with four spaces instead of TAB.

  • 增加新特性和新模块之前,请先到issues提交相关特性说明,经过讨论评估确认后,再进行相应的代码提交,避免做无用工作。
  • 编写友好可读的提交信息,并使用与工程代码相同的代码规范,代码请用4个空格字符代替tab缩进。
  • 请提交代码到dev分支,如果通过,我们会在特定时间合并到master分支上。
  • 为了规范化提交日志的格式,commit消息,不要用中文,请用英文描述。

-- https://cmake.org/cmake/help/latest/variable/CMAKE_ANDROID_STL_TYPE.html
local supported_runtimes = {
"none", "system",
"gabi++_static", "gabi++_shared",
Copy link
Member

Choose a reason for hiding this comment

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

package:has_runtime only support

"gnustl_static", "gnustl_shared",
"c++_static", "c++_shared",
"stlport_static", "stlport_shared"

Copy link
Member Author

Choose a reason for hiding this comment

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

I know but maybe it will be extended in the future, so I put all runtimes supported by this cmake option

Copy link
Member

Choose a reason for hiding this comment

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

Please add them when xmake actually supports them. Also, the runtime names of cmake and ndk are not necessarily the same as the runtimes of xmake, and may need to be mapped, so don't add some unknown runtime names for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough, done

if package:has_runtime(runtime) then
table.insert(configs, "-DCMAKE_ANDROID_STL_TYPE=" .. runtime)
break
end
end
Copy link
Member

@waruqi waruqi Apr 1, 2024

Choose a reason for hiding this comment

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

I think this will be better.

local runtime = package:runtimes()
if runtime then
    table.insert(configs, "-DCMAKE_ANDROID_STL_TYPE=" .. runtime)
end

Copy link
Member Author

Choose a reason for hiding this comment

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

what if multiple runtimes have been set?

Copy link
Member

Choose a reason for hiding this comment

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

only one runtime.

set_runtimes("c++_static", "c++_shared", "gnustl_static", "gnustl_shared", "stlport_static", "stlport_shared")

set_runtimes("c++_static", "MT")

-> package:runtimes() only return c++_static

Copy link
Member Author

Choose a reason for hiding this comment

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

I got confused by the plural form (runtimes instead of runtime).

Copy link
Member

Choose a reason for hiding this comment

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

For some toolchains and platforms that support multiple runtimes, it may have multiple values, but for android/msvc, only one value is possible

@waruqi waruqi merged commit a86468f into xmake-io:dev Apr 1, 2024
19 checks passed
@waruqi waruqi added this to the v2.9.1 milestone Apr 1, 2024
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.

2 participants