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

compile_commands.json #133

Closed
71e6fd52 opened this Issue Jul 18, 2017 · 36 comments

Comments

Projects
None yet
2 participants
@71e6fd52
Contributor

71e6fd52 commented Jul 18, 2017

Support generate compile_commands.json?

In cmake, it is CMAKE_EXPORT_COMPILE_COMMANDS

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 18, 2017

Member

You can write a custom script or plugin task to export it by calling core.tool.compiler module. for example:

target("xxx")
    after_build(function (target)
        import("core.tool.compiler")
        for sourcekind, sourcebatch in pairs(target:sourcebatches()) do
            for index, sourcefile in ipairs(sourcebatch.sourcefiles) do
                local command = compiler.compcmd(sourcefile, sourcebatch.objectfiles[index], {target = target, sourcekind = sourcekind})
                print(command)
            end
        end
    end)

Or You can write a custom plugin named export_cmds and run this plugin to export it.

Define plugin task

target("export_cmds")
    set_category("plugin")
    on_run(function()

        -- imports
        import("core.base.option")
        import("core.tool.compiler")
        import("core.project.project")

        -- load project
        os.cd(os.projectdir())
        config.load()
        platform.load(config.plat())
        project.load() 

        -- export compiler commands for each targets
        local cmds = {}
        for name, target in pairs(project.targets()) do
            for sourcekind, sourcebatch in pairs(target:sourcebatches()) do
                for index, sourcefile in ipairs(sourcebatch.sourcefiles) do
                    cmds[sourcefile] = compiler.compcmd(sourcefile, sourcebatch.objectfiles[index], {target = target, sourcekind = sourcekind})
                end
            end
        end

        -- save to file
        io.save(option.get("output"), cmds)
    end)
    
    -- set menu
    set_menu {
                -- usage
                usage = "xmake echo [options]"

                -- description
            ,   description = "Echo the given info!"

                -- options
            ,   options = 
                {
                ,   {'o', "output",      "kv", nil,   "Set the output file"}
                }
            

Run command:

xmake export_cmds -o /tmp/xxxx.txt

You can see write a custom plugin about the plugin development.

Related extension modules:

Related builtin modules:

Related plugin example:

Note: Here's just an example, you need to make some changes yourself.

Member

waruqi commented Jul 18, 2017

You can write a custom script or plugin task to export it by calling core.tool.compiler module. for example:

target("xxx")
    after_build(function (target)
        import("core.tool.compiler")
        for sourcekind, sourcebatch in pairs(target:sourcebatches()) do
            for index, sourcefile in ipairs(sourcebatch.sourcefiles) do
                local command = compiler.compcmd(sourcefile, sourcebatch.objectfiles[index], {target = target, sourcekind = sourcekind})
                print(command)
            end
        end
    end)

Or You can write a custom plugin named export_cmds and run this plugin to export it.

Define plugin task

target("export_cmds")
    set_category("plugin")
    on_run(function()

        -- imports
        import("core.base.option")
        import("core.tool.compiler")
        import("core.project.project")

        -- load project
        os.cd(os.projectdir())
        config.load()
        platform.load(config.plat())
        project.load() 

        -- export compiler commands for each targets
        local cmds = {}
        for name, target in pairs(project.targets()) do
            for sourcekind, sourcebatch in pairs(target:sourcebatches()) do
                for index, sourcefile in ipairs(sourcebatch.sourcefiles) do
                    cmds[sourcefile] = compiler.compcmd(sourcefile, sourcebatch.objectfiles[index], {target = target, sourcekind = sourcekind})
                end
            end
        end

        -- save to file
        io.save(option.get("output"), cmds)
    end)
    
    -- set menu
    set_menu {
                -- usage
                usage = "xmake echo [options]"

                -- description
            ,   description = "Echo the given info!"

                -- options
            ,   options = 
                {
                ,   {'o', "output",      "kv", nil,   "Set the output file"}
                }
            

Run command:

xmake export_cmds -o /tmp/xxxx.txt

You can see write a custom plugin about the plugin development.

Related extension modules:

Related builtin modules:

Related plugin example:

Note: Here's just an example, you need to make some changes yourself.

@waruqi waruqi added the discussion label Jul 18, 2017

@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 18, 2017

Contributor

I try, but it is a error on local command = compiler.compcmd(sourcefiles, sourcebatch.objectfiles[index], {target = target, sourcekind = sourcekind})

error: /usr/share/xmake/core/base/os.lua:592: /usr/share/xmake/core/tool/compiler.lua:86: assertion failed!
stack traceback:
    [C]: in function 'assert'
    [/usr/share/xmake/core/tool/compiler.lua:86]: in function 'load'
    [...xmake/core/sandbox/modules/import/core/tool/compiler.lua:57]: in function 'compcmd'
    [/data/datsd/program/factorio/Factorio-Mod-info/xmake.lua:24]: in function 'script'
    [/usr/share/xmake/actions/build/builder.lua:55]: in function '_build_target'
    [/usr/share/xmake/actions/build/builder.lua:77]: in function '_build_target_and_deps'
    [/usr/share/xmake/actions/build/builder.lua:143]: in function 'build'
    [/usr/share/xmake/actions/build/main.lua:73]:

stack traceback:
    [C]: in function 'error'
    [/usr/share/xmake/core/base/os.lua:592]: in function 'raise'
    [/usr/share/xmake/core/sandbox/modules/os.lua:419]: in function 'raise'
    [/usr/share/xmake/actions/build/main.lua:82]: in function 'catch'
    [/usr/share/xmake/core/sandbox/modules/try.lua:104]: in function 'try'
    [/usr/share/xmake/actions/build/main.lua:69]:
    [C]: in function 'load'
    [/usr/share/xmake/core/project/task.lua:426]: in function 'run'
    [/usr/share/xmake/core/main.lua:203]:

And I can't find document about sourcebatches.

Contributor

71e6fd52 commented Jul 18, 2017

I try, but it is a error on local command = compiler.compcmd(sourcefiles, sourcebatch.objectfiles[index], {target = target, sourcekind = sourcekind})

error: /usr/share/xmake/core/base/os.lua:592: /usr/share/xmake/core/tool/compiler.lua:86: assertion failed!
stack traceback:
    [C]: in function 'assert'
    [/usr/share/xmake/core/tool/compiler.lua:86]: in function 'load'
    [...xmake/core/sandbox/modules/import/core/tool/compiler.lua:57]: in function 'compcmd'
    [/data/datsd/program/factorio/Factorio-Mod-info/xmake.lua:24]: in function 'script'
    [/usr/share/xmake/actions/build/builder.lua:55]: in function '_build_target'
    [/usr/share/xmake/actions/build/builder.lua:77]: in function '_build_target_and_deps'
    [/usr/share/xmake/actions/build/builder.lua:143]: in function 'build'
    [/usr/share/xmake/actions/build/main.lua:73]:

stack traceback:
    [C]: in function 'error'
    [/usr/share/xmake/core/base/os.lua:592]: in function 'raise'
    [/usr/share/xmake/core/sandbox/modules/os.lua:419]: in function 'raise'
    [/usr/share/xmake/actions/build/main.lua:82]: in function 'catch'
    [/usr/share/xmake/core/sandbox/modules/try.lua:104]: in function 'try'
    [/usr/share/xmake/actions/build/main.lua:69]:
    [C]: in function 'load'
    [/usr/share/xmake/core/project/task.lua:426]: in function 'run'
    [/usr/share/xmake/core/main.lua:203]:

And I can't find document about sourcebatches.

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 18, 2017

Member

Please update xmake to master version and try it again.

I will update document and publish the new version (v2.1.5) in recent weeks. Please wait some time.

And you can run table.dump(target:sourcebatches()) or print(target:sourcebatches()) to see it's all contents.

Member

waruqi commented Jul 18, 2017

Please update xmake to master version and try it again.

I will update document and publish the new version (v2.1.5) in recent weeks. Please wait some time.

And you can run table.dump(target:sourcebatches()) or print(target:sourcebatches()) to see it's all contents.

@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 18, 2017

Contributor
make demo
make[3]: 警告: jobserver 不可用: 正使用 -j1。添加 “+” 到父 make 的规则。
ccache compile.r xmake.c
link demo.b
make[3]: *** [/home/datsd/.cache/pacaur/xmake-git/src/xmake/core/suffix.mak:304:demo.b] 错误 1
make[2]: *** [/home/datsd/.cache/pacaur/xmake-git/src/xmake/core/suffix.mak:304:SUB_PROS_demo_all] 错误 2
make[1]: *** [makefile:41:all] 错误 2
make: *** [makefile:49:build] 错误 2
==> 错误: 在 build() 中发生一个错误。
Contributor

71e6fd52 commented Jul 18, 2017

make demo
make[3]: 警告: jobserver 不可用: 正使用 -j1。添加 “+” 到父 make 的规则。
ccache compile.r xmake.c
link demo.b
make[3]: *** [/home/datsd/.cache/pacaur/xmake-git/src/xmake/core/suffix.mak:304:demo.b] 错误 1
make[2]: *** [/home/datsd/.cache/pacaur/xmake-git/src/xmake/core/suffix.mak:304:SUB_PROS_demo_all] 错误 2
make[1]: *** [makefile:41:all] 错误 2
make: *** [makefile:49:build] 错误 2
==> 错误: 在 build() 中发生一个错误。
@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 18, 2017

Member

Please run ./script/get.sh __local__ to compile and install xmake and run the following command to get verbose error info if fails:

$ cd core
$ make output
Member

waruqi commented Jul 18, 2017

Please run ./script/get.sh __local__ to compile and install xmake and run the following command to get verbose error info if fails:

$ cd core
$ make output
@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 18, 2017

Contributor

为什么我要使用 scripts/get.sh,(scripts/get.sh 的错误提示)和( make build 之后进入 core 执行 make output) 一样。

[make output result](https://cfp.vim-cn.com/cbds2)

Contributor

71e6fd52 commented Jul 18, 2017

为什么我要使用 scripts/get.sh,(scripts/get.sh 的错误提示)和( make build 之后进入 core 执行 make output) 一样。

[make output result](https://cfp.vim-cn.com/cbds2)

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 18, 2017

Member

这两个都可以。。只是安装位置不一样,script/get.sh会自动安装,并且不需要sudo,如果你之前一直是 make build的,那就还是用这个吧。。

执行make output后,还是上面的那些错误信息,没有更多提示信息吗?你这边是什么系统环境,之前的版本编译没有问题吗?

如果你现在的版本是2.1.4之前的老版本,可以先改成下面试下(主要就是compiler.compcmd后两个参数传参上在新版本有些变动,所以尽量用新版本):

target("xxx")
    after_build(function (target)
        import("core.tool.compiler")
        for sourcekind, sourcebatch in pairs(target:sourcebatches()) do
            for index, sourcefile in ipairs(sourcebatch.sourcefiles) do
                local command = compiler.compcmd(sourcefile, sourcebatch.objectfiles[index], target, sourcekind)
                print(command)
            end
        end
    end)
Member

waruqi commented Jul 18, 2017

这两个都可以。。只是安装位置不一样,script/get.sh会自动安装,并且不需要sudo,如果你之前一直是 make build的,那就还是用这个吧。。

执行make output后,还是上面的那些错误信息,没有更多提示信息吗?你这边是什么系统环境,之前的版本编译没有问题吗?

如果你现在的版本是2.1.4之前的老版本,可以先改成下面试下(主要就是compiler.compcmd后两个参数传参上在新版本有些变动,所以尽量用新版本):

target("xxx")
    after_build(function (target)
        import("core.tool.compiler")
        for sourcekind, sourcebatch in pairs(target:sourcebatches()) do
            for index, sourcefile in ipairs(sourcebatch.sourcefiles) do
                local command = compiler.compcmd(sourcefile, sourcebatch.objectfiles[index], target, sourcekind)
                print(command)
            end
        end
    end)
@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 18, 2017

Contributor

错误信息是 make output result
xmake --version 的结果是 v2.1.5.201706041804

Contributor

71e6fd52 commented Jul 18, 2017

错误信息是 make output result
xmake --version 的结果是 v2.1.5.201706041804

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 18, 2017

Member

或者这样吧 后两天 我写个导出工程所有信息到 文件的通用扩展模块, 里面包含工程所有target的各种属性和编译链接信息 。。

之前也有用户写vim插件跟xmake 交互,需要通过这种方式交互工程的配置信息。。所以独立封装和模块 应该还是蛮有用的。。

Member

waruqi commented Jul 18, 2017

或者这样吧 后两天 我写个导出工程所有信息到 文件的通用扩展模块, 里面包含工程所有target的各种属性和编译链接信息 。。

之前也有用户写vim插件跟xmake 交互,需要通过这种方式交互工程的配置信息。。所以独立封装和模块 应该还是蛮有用的。。

@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 18, 2017

Contributor

之前一直是 pacaur -Syu, 用的 xmake-git(这句在上面,回复

之前一直是 make build

)

Contributor

71e6fd52 commented Jul 18, 2017

之前一直是 pacaur -Syu, 用的 xmake-git(这句在上面,回复

之前一直是 make build

)

@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 18, 2017

Contributor

不过为什么编译不了 xmake

Contributor

71e6fd52 commented Jul 18, 2017

不过为什么编译不了 xmake

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 18, 2017

Member

这个错误可能是你这gcc版本大于6.0 默认启用pie了 但是内置的tbox库是用老的gcc版本编译的 没启用pie 导致最后链接的时候不兼容了这个问题我至少应该修复过 我再看看如何解决

你最近升级过gcc? 现在gcc版本多少?

Member

waruqi commented Jul 18, 2017

这个错误可能是你这gcc版本大于6.0 默认启用pie了 但是内置的tbox库是用老的gcc版本编译的 没启用pie 导致最后链接的时候不兼容了这个问题我至少应该修复过 我再看看如何解决

你最近升级过gcc? 现在gcc版本多少?

@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 18, 2017

Contributor

老版本的代码可以的,你确定是 2.1.4之前的老版本?
省略也可以

Contributor

71e6fd52 commented Jul 18, 2017

老版本的代码可以的,你确定是 2.1.4之前的老版本?
省略也可以

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 18, 2017

Member

一开始贴的那段代码 是我最近刚重构compiler.compcmd 才做的修改 之前安装的2.1.5 master版本 也可能是老的方式

Member

waruqi commented Jul 18, 2017

一开始贴的那段代码 是我最近刚重构compiler.compcmd 才做的修改 之前安装的2.1.5 master版本 也可能是老的方式

@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 18, 2017

Contributor

compile_commands.json 的格式在 https://clang.llvm.org/docs/JSONCompilationDatabase.html ,clang-tidy 会用到

导出 compile_commands.json 可以加入 xmake

Contributor

71e6fd52 commented Jul 18, 2017

compile_commands.json 的格式在 https://clang.llvm.org/docs/JSONCompilationDatabase.html ,clang-tidy 会用到

导出 compile_commands.json 可以加入 xmake

@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 18, 2017

Contributor

[Re: 你最近升级过gcc? 现在gcc版本多少?] Archlinux ^_^, gcc 版本 7.1.1 20170630

Contributor

71e6fd52 commented Jul 18, 2017

[Re: 你最近升级过gcc? 现在gcc版本多少?] Archlinux ^_^, gcc 版本 7.1.1 20170630

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 18, 2017

Member

好的。在2.1.5的新版本中,我会考虑加上这个导出的扩展接口,放置到 modules 目录下,通过import导入后使用就行了,不过需要稍微等上一会,最近刚重构好新版本,还有点不稳定,正在优化中。。

Member

waruqi commented Jul 18, 2017

好的。在2.1.5的新版本中,我会考虑加上这个导出的扩展接口,放置到 modules 目录下,通过import导入后使用就行了,不过需要稍微等上一会,最近刚重构好新版本,还有点不稳定,正在优化中。。

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 18, 2017

Member

[Re: 你最近升级过gcc? 现在gcc版本多少?] Archlinux ^_^, gcc 版本 7.1.1 20170630

看来确实gcc版本太新了导致,之前只在gcc6上测试过, gcc7还没测试过,之后我看看怎么修复下。。

现在你可以先用我刚提供的老的代码方式先试试,也就最后两个参数的传参上有些变动,其他没有任何改动。。

Member

waruqi commented Jul 18, 2017

[Re: 你最近升级过gcc? 现在gcc版本多少?] Archlinux ^_^, gcc 版本 7.1.1 20170630

看来确实gcc版本太新了导致,之前只在gcc6上测试过, gcc7还没测试过,之后我看看怎么修复下。。

现在你可以先用我刚提供的老的代码方式先试试,也就最后两个参数的传参上有些变动,其他没有任何改动。。

@waruqi waruqi added this to the v2.1.5 milestone Jul 19, 2017

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 19, 2017

Member

@745275633 我dev分支上,已经加上对 compile_commands.json的支持了,可以运行命令:

$ xmake project -k compile_commands

在当前工程目录下生成compile_commands.json

或者指定输出目录:

$ xmake project -k compile_commands -o /tmp/dir

或者指定工程目录:

$ xmake -P projectdir project -k compile_commands -o /tmp/dir

xmake project 为工程生成插件,之前可以生成makefile, vs201x等各种IDE工程文件,现在增加对 clang的 compile_commands.json格式文件生成。。

如果要在 xmake.lua 进行调用,可以通过core.project.task模块:

target("xxx")
    after_build(function (target)
        import("core.project.task")
        task.run("project", {kind = "compile_commands", outputdir = "tmp/dir"})
    end)

并且已用clang-tidy对tbox工程生成的compile_commands.json进行测试验证通过。。

Member

waruqi commented Jul 19, 2017

@745275633 我dev分支上,已经加上对 compile_commands.json的支持了,可以运行命令:

$ xmake project -k compile_commands

在当前工程目录下生成compile_commands.json

或者指定输出目录:

$ xmake project -k compile_commands -o /tmp/dir

或者指定工程目录:

$ xmake -P projectdir project -k compile_commands -o /tmp/dir

xmake project 为工程生成插件,之前可以生成makefile, vs201x等各种IDE工程文件,现在增加对 clang的 compile_commands.json格式文件生成。。

如果要在 xmake.lua 进行调用,可以通过core.project.task模块:

target("xxx")
    after_build(function (target)
        import("core.project.task")
        task.run("project", {kind = "compile_commands", outputdir = "tmp/dir"})
    end)

并且已用clang-tidy对tbox工程生成的compile_commands.json进行测试验证通过。。

@waruqi waruqi added the in progress label Jul 19, 2017

@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 20, 2017

Contributor
Contributor

71e6fd52 commented Jul 20, 2017

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 20, 2017

Member

@745275633 你这边测试可用吗?ok的话。。我就close 这个issues了。。

Member

waruqi commented Jul 20, 2017

@745275633 你这边测试可用吗?ok的话。。我就close 这个issues了。。

@waruqi waruqi removed the in progress label Jul 20, 2017

@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 20, 2017

Contributor

我以为是你本地分支


编译错误,错误看起来和上次一样

Contributor

71e6fd52 commented Jul 20, 2017

我以为是你本地分支


编译错误,错误看起来和上次一样

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 20, 2017

Member

@745275633 哦 master分支我还没更新,还在dev分支里面,你之前那个编译错误问题 我这边还没环境,所以还没开始修,先把compile_commands的特性实现了,编译错误等我过两天装好环境再修下。。

你可以吧 所有lua脚本覆盖到安装目录下: /usr/local/share/xmake,来升级版本进行尝试。。或者临时切换脚本目录,切到新版本上去运行,例如:

$ export XMAKE_PROGRAM_DIR=newver_xmake_projectdir/xmake
$ cd projectdir
$ xmake --version
$ xmake project -k compile_commands
Member

waruqi commented Jul 20, 2017

@745275633 哦 master分支我还没更新,还在dev分支里面,你之前那个编译错误问题 我这边还没环境,所以还没开始修,先把compile_commands的特性实现了,编译错误等我过两天装好环境再修下。。

你可以吧 所有lua脚本覆盖到安装目录下: /usr/local/share/xmake,来升级版本进行尝试。。或者临时切换脚本目录,切到新版本上去运行,例如:

$ export XMAKE_PROGRAM_DIR=newver_xmake_projectdir/xmake
$ cd projectdir
$ xmake --version
$ xmake project -k compile_commands
@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 20, 2017

Contributor

我用 make build --trace 发现编译用的是 clang, clang v4.0.1

Contributor

71e6fd52 commented Jul 20, 2017

我用 make build --trace 发现编译用的是 clang, clang v4.0.1

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 20, 2017

Member

好的,后两天我会尝试修下这个编译问题。。

Member

waruqi commented Jul 20, 2017

好的,后两天我会尝试修下这个编译问题。。

@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 20, 2017

Contributor

加上 CC=gcc 之后前面的用了 gcc

但是出错的这句 clang -odemo.b xmake.o -m64 -s -L../luajit -L../xmake -L/home/datsd/.cache/pacaur/xmake-git/xmake/core/pkg/base.pkg/lib/release/linux/x86_64 -L/home/datsd/.cache/pacaur/xmake-git/xmake/core/pkg/tbox.pkg/lib/release/linux/x86_64 -lxmaker -lluajitr -ltbox -lreadline -lm -ldl -lpthread 2> /tmp/xmake.out 还是用的 clang

Contributor

71e6fd52 commented Jul 20, 2017

加上 CC=gcc 之后前面的用了 gcc

但是出错的这句 clang -odemo.b xmake.o -m64 -s -L../luajit -L../xmake -L/home/datsd/.cache/pacaur/xmake-git/xmake/core/pkg/base.pkg/lib/release/linux/x86_64 -L/home/datsd/.cache/pacaur/xmake-git/xmake/core/pkg/tbox.pkg/lib/release/linux/x86_64 -lxmaker -lluajitr -ltbox -lreadline -lm -ldl -lpthread 2> /tmp/xmake.out 还是用的 clang

@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 20, 2017

Contributor

我进入 core/src/demo 手动执行了 gcc -odemo.b xmake.o -m64 -s -L../luajit -L../xmake -L/home/datsd/.cache/pacaur/xmake-git/xmake/core/pkg/base.pkg/lib/release/linux/x86_64 -L/home/datsd/.cache/pacaur/xmake-git/xmake/core/pkg/tbox.pkg/lib/release/linux/x86_64 -lxmaker -lluajitr -ltbox -lreadline -lm -ldl -lpthread 2> /tmp/xmake.out (把 clang 换成了 gcc) 编译通过了。但是我怎么继续编译。

Contributor

71e6fd52 commented Jul 20, 2017

我进入 core/src/demo 手动执行了 gcc -odemo.b xmake.o -m64 -s -L../luajit -L../xmake -L/home/datsd/.cache/pacaur/xmake-git/xmake/core/pkg/base.pkg/lib/release/linux/x86_64 -L/home/datsd/.cache/pacaur/xmake-git/xmake/core/pkg/tbox.pkg/lib/release/linux/x86_64 -lxmaker -lluajitr -ltbox -lreadline -lm -ldl -lpthread 2> /tmp/xmake.out (把 clang 换成了 gcc) 编译通过了。但是我怎么继续编译。

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 20, 2017

Member

CC=gcc只是替换了编译器,你可以再加上LD=gcc或者LD=g++替换下链接器。

$ export CC=gcc
$ export LD=gcc
$ make build
$ sudo make install
Member

waruqi commented Jul 20, 2017

CC=gcc只是替换了编译器,你可以再加上LD=gcc或者LD=g++替换下链接器。

$ export CC=gcc
$ export LD=gcc
$ make build
$ sudo make install
@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 20, 2017

Contributor

编译可以了(为什么默认是 clang


xmake project -k compile_commands 报错 error: the project kind(compile_commands) is not supported!

Contributor

71e6fd52 commented Jul 20, 2017

编译可以了(为什么默认是 clang


xmake project -k compile_commands 报错 error: the project kind(compile_commands) is not supported!

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 20, 2017

Member

因为个人比较喜欢clang 所以默认检测到clang后 就用clang编译xmake了 = =

你确定下载的是dev分支的代码?看错误提示还是老版本 没这插件 master上还没更新哦

Member

waruqi commented Jul 20, 2017

因为个人比较喜欢clang 所以默认检测到clang后 就用clang编译xmake了 = =

你确定下载的是dev分支的代码?看错误提示还是老版本 没这插件 master上还没更新哦

@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 20, 2017

Contributor

喜欢 clang 还没让 clang 编译通过


是dev分支的代码,不过忘 pull 了。


xmake project -k compile_commands 是生成了 compile_commands.json,但是没我要的 -std 参数

Contributor

71e6fd52 commented Jul 20, 2017

喜欢 clang 还没让 clang 编译通过


是dev分支的代码,不过忘 pull 了。


xmake project -k compile_commands 是生成了 compile_commands.json,但是没我要的 -std 参数

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 20, 2017

Member

喜欢 clang 还没让 clang 编译通过

这个clang编译的错误之后我会修下的

xmake project -k compile_commands 是生成了 compile_commands.json,但是没我要的 -std 参数

这个是根据xmake.lua的配置来的,你先确认下有没有设置类似:add_cxflags("-std=c11"),或者set_languages("c11")的配置。

如果有设置,然后可以运行下 xmake -v 编译,看看输出的详细编译参数里面有没有带上 -std

Member

waruqi commented Jul 20, 2017

喜欢 clang 还没让 clang 编译通过

这个clang编译的错误之后我会修下的

xmake project -k compile_commands 是生成了 compile_commands.json,但是没我要的 -std 参数

这个是根据xmake.lua的配置来的,你先确认下有没有设置类似:add_cxflags("-std=c11"),或者set_languages("c11")的配置。

如果有设置,然后可以运行下 xmake -v 编译,看看输出的详细编译参数里面有没有带上 -std

@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 20, 2017

Contributor

我设置了 set_languages("gnu++14") 而不是 gnuxx14,现在行了
btw,为什么不是 c++ 要用 cxx

Contributor

71e6fd52 commented Jul 20, 2017

我设置了 set_languages("gnu++14") 而不是 gnuxx14,现在行了
btw,为什么不是 c++ 要用 cxx

@71e6fd52 71e6fd52 closed this Jul 20, 2017

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Jul 20, 2017

Member

当初就这么设计的,什么原因我也忘了,现在就不改了。。

Member

waruqi commented Jul 20, 2017

当初就这么设计的,什么原因我也忘了,现在就不改了。。

@71e6fd52

This comment has been minimized.

Show comment
Hide comment
@71e6fd52

71e6fd52 Jul 20, 2017

Contributor

全加上

Contributor

71e6fd52 commented Jul 20, 2017

全加上

@waruqi

This comment has been minimized.

Show comment
Hide comment
@waruqi

waruqi Aug 10, 2017

Member

linux上我改了下,优先采用gcc来编译 core 来解决链接问题,已入master,2.1.6版本,你这编译安装应该不需要改CC, LD了

Member

waruqi commented Aug 10, 2017

linux上我改了下,优先采用gcc来编译 core 来解决链接问题,已入master,2.1.6版本,你这编译安装应该不需要改CC, LD了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment