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

咨询个奇怪的问题(mac下编译android程序相关) #757

Closed
fasiondog opened this issue Apr 8, 2020 · 7 comments
Closed

咨询个奇怪的问题(mac下编译android程序相关) #757

fasiondog opened this issue Apr 8, 2020 · 7 comments
Milestone

Comments

@fasiondog
Copy link
Contributor

咨询个奇怪的问题:今天帮新同事安装编译,试了两台mac都出现问题。我用Python调用xmake正常,但直接在xmake里执行xmake命令却总是失败。python里依次调用要完全可以编译,但是我python后面还要再编译一个单元测试程序,就会出现类似的错误,所以试验在 shell里执行,结果python正常编译的两条命令,在shell里也会失败。我自用的机器又完全没问题。xmake都是用xmake update dev升级到最新。(编译android程序,本机编译正常)

命令1:
xmake f -v -D -y -p android --ndk="/Users/yh-imac/Library/Android/sdk/ndk-bundle/" --ndk_sdkver=22 --android_sdk=/Users/yh-imac/Library/Android -a armv7-a --tiny=n --purpose=test

命令2:
xmake -b yhsdk

执行命令2的输出:
target unit-test: loading yihua.rules ...
target yhsdk: loading yihua.rules ...
configure
{
ld = /Users/yh-imac/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++
ccache = true
host = macosx
purpose = test
bin = /Users/yh-imac/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin
ndk_stdcxx = true
plat = android
sdk = /Users/yh-imac/Library/Android
ndk = /Users/yh-imac/Library/Android/sdk/ndk-bundle/
header_only = false
buildir = build
ndk_toolchains_ver = 4.9
boost-python-suffix = 3X
ndk_sdkver = 22
arch = armv7-a
runtime_link = static
sh = /Users/yh-imac/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++
gcc_toolchain = /Users/yh-imac/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64
mode = release
lto = false
cxx = /Users/yh-imac/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++
cross = arm-linux-androideabi-
rtti = true
kind = static
tiny = false
android_sdk = /Users/yh-imac/Library/Android
exception = true
ndkver = 21
}
�[0m�[1;38;5;1;1merror: �[0m@programdir/core/main.lua:261: @programdir/actions/build/main.lua:124: ...mdir/core/sandbox/modules/import/core/base/scheduler.lua:87: ...mdir/core/sandbox/modules/import/core/base/scheduler.lua:47: @programdir/modules/private/async/runjobs.lua:213: @programdir/modules/core/tools/gcc.lua:233: bad argument #1 to 'args' (string expected, got nil)
stack traceback:
[C]: in function 'args'
[@programdir/modules/core/tools/gcc.lua:233]: in function 'mapper'
[@programdir/core/tool/builder.lua:462]: in function '_add_flags_from_language'
[@programdir/core/tool/builder.lua:316]: in function '_add_flags_from_target'
[@programdir/core/tool/compiler.lua:305]: in function 'compflags'
[@programdir/modules/private/action/build/object.lua:42]: in function 'script'
[@programdir/modules/private/action/build/object.lua:90]: in function '_build_object'
[@programdir/modules/private/action/build/object.lua:115]: in function 'jobfunc'
[@programdir/modules/private/async/runjobs.lua:190]:
[C]: in function 'trycall'
[@programdir/core/sandbox/modules/try.lua:121]: in function 'try'
[@programdir/modules/private/async/runjobs.lua:187]: in function 'cotask'
[@programdir/core/base/scheduler.lua:317]:

stack traceback:
[C]: in function 'error'
@programdir/core/base/os.lua:787: in function 'raise'
@programdir/modules/private/async/runjobs.lua:213: in function 'catch'
@programdir/core/sandbox/modules/try.lua:127: in function 'try'
@programdir/modules/private/async/runjobs.lua:187: in function 'cotask'
@programdir/core/base/scheduler.lua:317: in function <@programdir/core/base/scheduler.lua:315>
stack traceback:
[C]: in function 'error'
@programdir/core/base/os.lua:787: in function 'raise'
...mdir/core/sandbox/modules/import/core/base/scheduler.lua:47: in function 'co_start_named'
@programdir/modules/private/async/runjobs.lua:185: in function <@programdir/modules/private/async/runjobs.lua:144>
[C]: in function 'trycall'
@programdir/core/base/scheduler.lua:423: in function 'co_group_begin'
...mdir/core/sandbox/modules/import/core/base/scheduler.lua:85: in function 'co_group_begin'
@programdir/modules/private/async/runjobs.lua:144: in function 'runjobs'
@programdir/actions/build/build.lua:221: in function 'build'
@programdir/actions/build/main.lua:116: in function <@programdir/actions/build/main.lua:111>
[C]: in function 'trycall'
@programdir/core/sandbox/modules/try.lua:121: in function 'try'
@programdir/actions/build/main.lua:110: in function <@programdir/actions/build/main.lua:83>
[C]: in function 'load'
@programdir/core/base/task.lua:520: in function 'run'
@programdir/core/main.lua:259: in function 'cotask'
@programdir/core/base/scheduler.lua:317: in function <@programdir/core/base/scheduler.lua:315>
stack traceback:
[C]: in function 'error'
@programdir/core/base/os.lua:787: in function 'raise'
@programdir/core/main.lua:261: in function 'cotask'
@programdir/core/base/scheduler.lua:317: in function <@programdir/core/base/scheduler.lua:315>�[0m

@waruqi
Copy link
Member

waruqi commented Apr 8, 2020

你可以在 tools/gcc.lua 的下面这个位置加点print 给我看下:

function nf_includedir(self, dir)
    print(dir)
    return "-I" .. os.args(path.translate(dir))
end

我怀疑有个 includedir 不对,导致 path.translate 返回nil了。给我看下出错后的dir值,我需要分析下为啥会返回nil

这个path.translate返回nil的情况,目前看 只有在遇到 ~/xxx的路径,里面取$HOME环境变量为空的时候,才会出现。。

你也可以确认下,$HOME 环境变量具体是否有值,

@waruqi
Copy link
Member

waruqi commented Apr 8, 2020

我大概知道什么原因了,应该是你这有个includedir的配置项是""导致,path.translate返回了nil,这块我明天处理兼容下

不过为啥会有invludedir的空串设置,你可以检查下xmake.lua看看,我明天尝试加些检测 检测下参数输入

@waruqi waruqi added this to the v2.3.3 milestone Apr 8, 2020
@waruqi
Copy link
Member

waruqi commented Apr 9, 2020

我刚测试了下,传入add_includedirs("") 空串,应该不会报错才对,不过我也改进了下add_includedirs对于空串传入的检测,尽量提前报出来错误位置。

你可以先xmake update -s dev更新下,看看检测是否能检测到,然后在 includedir那个地方print下看看是哪个dir导致的问题。

@fasiondog
Copy link
Contributor Author

谢谢,通过新版错误提示解决了,应该是python里有设置环境变量的操作,shell里缺失

@waruqi
Copy link
Member

waruqi commented Apr 9, 2020

就是说 确实还是有地方导致 add_includedirs 传入了空串么?

@fasiondog
Copy link
Contributor Author

是的,python里会主动设置两个环境变量,但在shell里没有

@waruqi
Copy link
Member

waruqi commented Apr 9, 2020

哦哦。那我这里先close了

@waruqi waruqi closed this as completed Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants