xmake
xmake copied to clipboard
支持鸿蒙构建工具链
你在什么场景下需要该功能?
构建鸿蒙系统下的 cli 程序。类似 NDK,harmonyos 提供了一套基于 llvm 的工具链。
描述可能的解决方案
支持多一个平台 xmake -p harmonyos
描述你认为的候选方案
No response
其他信息
可以参考这个文档,用 cmake https://gitee.com/han_jin_fei/lycium/blob/master/doc/ohos_use_sdk/OHOS_SDK-Usage.md
Bot detected the issue body's language is not English, translate it automatically.
Title: Support Hongmeng build tool chain
In what scenario do you need this function?
Build the cli program under Hongmeng system. Similar to NDK, harmonyos provides a tool chain based on llvm.
Describe possible solutions
Support one more platform xmake -p harmonyos
Describe your alternatives
No response
other information
You can refer to this document and use cmake https://gitee.com/han_jin_fei/lycium/blob/master/doc/ohos_use_sdk/OHOS_SDK-Usage.md
后面可以考虑,但是得等排期,不一定立马会支持
Bot detected the issue body's language is not English, translate it automatically.
You can consider it later, but you have to wait for the schedule and may not be supported immediately.
我看它就是个 llvm ,你直接走交叉编译 或者 llvm toolchain 试试么。。
xmake f -p cross --toolchain=llvm --sdk=/xxx/xxx/llvm
xmake
我看它就是个 llvm ,你直接走交叉编译 或者 llvm toolchain 试试么。。
xmake f -p cross --toolchain=llvm --sdk=/xxx/xxx/llvm xmake
这个有试过,在编译的时候报了一个错误。我怀疑是启动 clang 的时候,没有传 --target=aarch64-linux-ohos,导致没有找到 sysroot。
[ 2%]: cache compiling.release src/lauxlib.c
[ 2%]: cache compiling.release src/lfunc.c
[ 2%]: cache compiling.release src/lundump.c
[ 2%]: cache compiling.release src/loadlib.c
[ 2%]: cache compiling.release src/lctype.c
[ 2%]: cache compiling.release src/lobject.c
[ 2%]: cache compiling.release src/linit.c
[ 2%]: cache compiling.release src/lstring.c
[ 2%]: cache compiling.release src/lmathlib.c
[ 2%]: cache compiling.release src/lstrlib.c
[ 2%]: cache compiling.release src/lopcodes.c
[ 2%]: cache compiling.release src/lvm.c
[ 2%]: cache compiling.release src/lstate.c
[ 2%]: cache compiling.release src/liolib.c
error: src/loadlib.c:17:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
^~~~~~~~~
if you want to get more verbose errors, please see:
那你自己加一下flags 不就好了。。xmake f -p cross --sdk= --toolchain=llvm --cxflags= --ldflags=
或者自定义个 toolchain 加上他们
Bot detected the issue body's language is not English, translate it automatically.
Then just add the flags yourself. . xmake f -p cross --sdk= --toolchain=llvm --cxflags= --ldflags=
Or customize a toolchain and add them
那你自己加一下flags 不就好了。。
xmake f -p cross --sdk= --toolchain=llvm --cxflags= --ldflags=或者自定义个 toolchain 加上他们
这个只是遇到的第一个问题。往后还有其他问题。我目前找个一个临时方案,就是用 xmake 来生成 cmake 清单,再用鸿蒙 sdk 自带的 cmake 和 cmake 配置来编译。
Bot detected the issue body's language is not English, translate it automatically.
Then just add the flags yourself. .
xmake f -p cross --sdk= --toolchain=llvm --cxflags= --ldflags=Or customize a toolchain and add them
This is just the first problem encountered. There are other questions going forward. I am currently looking for a temporary solution, which is to use xmake to generate the cmake list, and then use the cmake and cmake configuration that comes with Hongmeng SDK to compile.
如果要原生支持,那就只能等这边排期了
Bot detected the issue body's language is not English, translate it automatically.
If you want native support, you can only wait for the schedule here.
更新一下信息,我目前通过自定义 toolchain 的方法,也能解决,但估计原生支持的话,还要考虑更多情况。例如自动找到鸿蒙的 llvm,我目前是通过 --sdk 参数指定了路径。只要把 --target=aarch64-linux-ohos 参数传给鸿蒙自带的 llvm,很多参数都可以免掉。
toolchain("harmonyos")
set_kind("standalone")
set_toolset("cc", "clang")
set_toolset("cxx", "clang++")
set_toolset("ld", "clang")
set_toolset("sh", "clang")
set_toolset("ar", "llvm-ar")
set_toolset("ex", "llvm-ar")
set_toolset("strip", "llvm-strip")
set_toolset("mm", "clang")
set_toolset("mxx", "clang", "clang++")
set_toolset("as", "clang")
set_toolset("ranlib", "llvm-ranlib")
on_load(function (toolchain)
-- init flags for c/c++
toolchain:add("cxflags", "-m64 -fPIC -D__MUSL__=1 --target=aarch64-linux-ohos -march=armv8-a")
toolchain:add("ldflags", "-m64 -fPIC -D__MUSL__=1 --target=aarch64-linux-ohos -march=armv8-a")
toolchain:add("shflags", "-m64 -fPIC -D__MUSL__=1 --target=aarch64-linux-ohos -march=armv8-a")
end)
xmake f -p cross --toolchain=harmonyos --sdk=$HOME/Library/Huawei/Sdk/openharmony/9/native/llvm
已经支持 https://github.com/xmake-io/xmake/pull/4874