Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 11:34
    waruqi labeled #1715
  • 11:01
    xq114 opened #1715
  • 09:42
    myuanz opened #1714
  • Sep 27 15:18
    waruqi closed #1711
  • Sep 27 14:48
    waruqi closed #1656
  • Sep 27 14:48
    waruqi labeled #1656
  • Sep 27 14:45
    waruqi closed #1643
  • Sep 27 14:43
    waruqi closed #1661
  • Sep 27 14:40
    waruqi closed #1686
  • Sep 27 14:40
    waruqi milestoned #1686
  • Sep 27 14:40
    waruqi labeled #1686
  • Sep 27 14:39
    waruqi closed #1667
  • Sep 27 14:39
    waruqi labeled #1667
  • Sep 27 14:39
    waruqi closed #1709
  • Sep 27 14:39
    waruqi locked #1709
  • Sep 27 14:38
    waruqi milestoned #1711
  • Sep 27 14:38
    waruqi labeled #1711
  • Sep 27 09:52
    HiSunzhenliang closed #2
  • Sep 27 07:53
    ltmit opened #1711
  • Sep 26 13:33
    waruqi closed #638
Ho Ming Tsui
@alantsui_gitlab
about XMake?
ruki
@waruqi
@alantsui_gitlab
chaodad
@chaodad

在编译arm的固件时遇到了链接脚本检查通不过的问题诶

checking for the flags (-nostdlib) ... ok
checking for the flags (-T./link.ld) ... no

加上', {force = true}'可以编译通过

ruki
@waruqi
是的 link flags是通过尝试链接来检测的 有可能存在一定的失败率 。加force就行了,回头检测失败 我加个提示好了
Daniel Fort
@thenaquad_twitter

hi. i've got the following project structure:


.
├── src
│   ├── main.cpp
│   ├── some10.cpp
│   ├── some10.hpp
│   ├── some10_test.cpp
│   ├── some1.cpp
│   ├── some1.hpp
│   ├── some1_test.cpp
│   ├── some2.cpp
│   ├── some2.hpp
│   ├── some2_test.cpp
│   ├── some3.cpp
│   ├── some3.hpp
│   ├── some3_test.cpp
│   ├── some4.cpp
│   ├── some4.hpp
│   ├── some4_test.cpp
│   ├── some5.cpp
│   ├── some5.hpp
│   ├── some5_test.cpp
│   ├── some6.cpp
│   ├── some6.hpp
│   ├── some6_test.cpp
│   ├── some7.cpp
│   ├── some7.hpp
│   ├── some7_test.cpp
│   ├── some8.cpp
│   ├── some8.hpp
│   ├── some8_test.cpp
│   ├── some9.cpp
│   ├── some9.hpp
│   └── some9_test.cpp
└── xmake.lua

files with _test suffix are tests that should be treated as a separate targets, they depend on corresponding .cpp & .hpp files w/o _test suffix (that is some7_test.cpp depends on some7.{hpp,cpp})

and a debug/release target which includes main.cpp and all files that don't have _test suffix.

i'm trying to figure out how to do that in xmake.

my approach is to add mode check and dynamically define targets sort of like this:

local sources = {}

for _, fname in ipairs(os.files("$(projectdir)/src/*.cpp")) do
   local bname = path.basename(fname)
   if string.match(bname, "_test") then
     if is_mode("check") then
        target(string.gsub(bname, "_test\\.cpp"))
           add_files(fname, strings.gsub(fname, "_test\\.cpp$", ".cpp"))
        target_end()
     end
   else
     table.insert(sources, fname)
   end
done

But none of that works as xmake has different runtime domains and this should be run only in script domain.

So my question is: can i define dynamic targets for my case or xmake is not suitable for such purpose?

ruki
@waruqi
@thenaquad_twitter It is supported, I'll explain it in detail in the next two days.
ruki
@waruqi

-- add debug/release modes
add_rules("mode.debug", "mode.release")

-- test targets
for _, testfile in ipairs(os.files(path.join(os.projectdir(), "src", "*_test.cpp"))) do
    local testname = path.basename(testfile)
    target(testname)
        set_kind("binary")
        set_default(false)
        add_files(testfile)
        add_files(path.join(path.directory(testfile), testname:gsub("_test", "") .. ".cpp"))
    target_end()
end

-- test task
task("test")
    set_menu {usage = "xmake test [options]", description = "run all tests.", options = {}}
    on_run(function ()
        -- build tests
        local tests = {}
        for _, testfile in ipairs(os.files(path.join(os.projectdir(), "src", "*_test.cpp"))) do
            local testname = path.basename(testfile)
            table.insert(tests, testname)
            os.exec("xmake build %s", testname)
        end

        -- run tests
        for _, testname in ipairs(tests) do
            os.exec("xmake run %s", testname)
        end
    end)

-- demo target
target("demo")
    set_kind("binary")
    add_files("src/*.cpp|*_test.cpp")
@thenaquad_twitter You can use this xmake.lua and run xmake test to try it.
All test targets (with set_default(false)) will be not built by default, you can run xmake test or xmake build xxx_test or xmake --all to force to build these test targets.
Robert Butler
@lighth7015
how do I change xmake's built-in text (e.g. xmake f --config)?
ruki
@waruqi
@lighth7015 What text?
Armer song
@armersong
@waruqi 请问如何增加私有的conan仓库? xmake repo 增加失败
xmake repo -a cvte http://conan.opssee.com.cn:9300
error: 正克隆到 '/home/armers/projects/c++/xmake/conan-demo/.xmake/linux/x86_64/repositories/cvte'...
fatal: repository 'http://conan.opssee.com.cn:9300/' not found
ruki
@waruqi
@armersong 这个命令是用来添加xmake自己的私有仓库的,repo需要满足xmake自己的格式,具体参考xmake-repo,而conan的私有仓库 只能通过add_requires里面,传递参数到conan才行,具体conan包的使用 请看文档
另外这里我很少上,有问题尽量提github issues
Armer song
@armersong
收到。谢谢解答
kraigher
@kraigher
Hi, I am investigating different build systems and xmake is of interest. I am comparing it with premake (https://premake.github.io/) which is also LUA-based and seems superficially similar to xmake. Anyone here that has experience with both premake and xmake and could compare them? Why should I choose xmake over premake?
kraigher
@kraigher
I am not able to compile a file ending in .c as a C++ files. I read that add_files has a languages attribute but setting it seems to have no effect
Biswapriyo Nath
@Biswa96
Is there any build instruction to build xmake in Windows?
ruki
@waruqi
@kraigher add_files("*.c", {sourcekind = "cxx"})
@Biswa96 you need only run 'xmake' command in cmd to build projects.
ruki
@waruqi
if you want to build xmake, you can enter into core directory to build it. cd xmake/core xmake
Biswapriyo Nath
@Biswa96
I want to build xmake using GNU make or cmake. As per this msys2/MINGW-packages#6169.
make build
make build; make install
Biswapriyo Nath
@Biswa96

Some depends and makedepens can be added in PKGBUILD file. Example,

depends=('ncurses' 'readline' 'glibc' 'gcc-libs')

The compiled xmake binary has dependency on those .SO files (readelf -d).

ruki
@waruqi
ok
Biswapriyo Nath
@Biswa96
I'm not sure about it. Just asking.
ruki
@waruqi
I have improved xmake to compile it on mingw/msys/cygwin. It has been compiled successfully on msys/mingw for xmake/dev branch.
I am solving the compatibility issue of xmake on msys/mingw. I haven’t had time to improve PKGBUILD in these days, I will look at it later.
Biswapriyo Nath
@Biswa96
I thought xmake don't need any "real" code change because there is already a Windows build. OK, I'll check the dev branch.
Biswapriyo Nath
@Biswa96
Got this error:
make[3]: *** No rule to make target 'autogen/msys/jit/x86_64/lj_vm.o', needed by 'libluajitr.a'.  Stop.
make[2]: *** [/f/xmake/core/suffix.mak:305: DEP_PROS_luajit_all] Error 2
ruki
@waruqi

I thought xmake don't need any "real" code change because there is already a Windows build. OK, I'll check the dev branch.

It only support build xmake for msvc compiler. Some win api cannot process msys/mingw environments. e.g. GetEnvirnomentStrings cannot get all envs on msys, but getenv() ok.

and unix path, file system, ..

Got this error:

make[3]: *** No rule to make target 'autogen/msys/jit/x86_64/lj_vm.o', needed by 'libluajitr.a'.  Stop.
make[2]: *** [/f/xmake/core/suffix.mak:305: DEP_PROS_luajit_all] Error 2

please rununame command and let me look at it.

ruki
@waruqi
I feel the win api compatibility of msys/gcc is not particularly good. : (
Biswapriyo Nath
@Biswa96
uname here MINGW64_NT-10.0-19555
ruki
@waruqi
I forgot to submit some files, you can try pulling the dev branch again
Biswapriyo Nath
@Biswa96
It successfully compiled 🎉 BTW, did you add object files in dev branch in last commit?
ruki
@waruqi
yes.
Biswapriyo Nath
@Biswa96
One Q, why the package() step in PKGBUILD file is done with mkdir, cp like commands instead of make install?
ruki
@waruqi
Because when I wrote PKGBUILD, the make install script didn't exist, so I didn't replace it later.
Biswapriyo Nath
@Biswa96
OK, waiting for next release...
ruki
@waruqi
ok, I need to solve the compatibility issue of compiling xmake with msys/gcc. Currently xmake does not work well on msys. Please wait some time.
ruki
@waruqi
@Biswa96 I have published the release version (v2.3.1)
Biswapriyo Nath
@Biswa96
Also shouldn't the xmake shell script and xmake.exe name be different to remove any confusion while invoking from a shell?