xmake-io / xmake

๐Ÿ”ฅ A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.81k stars 774 forks source link

.xmake directory always appears next to xmake.lua #5439

Open LostTime76 opened 1 month ago

LostTime76 commented 1 month ago

Xmake Version

2.9.4

Operating System Version and Architecture

Windows 10

Describe Bug

No matter what I seem to do, an .xmake directory always appears next to the xmake.lua file, regardless of the current working directory.

Expected Behavior

cd target_dir xmake -P ../build

I am expecting all outputs generated by xmake to be within target_dir. It places a .xmake directory inside of target_dir AND inside of ../build directory where xmake.lua is. I do not want the scripts directory polluted in this example.

This seems to do with AppData/temp/xmake directory. This directory seems to store invocation dates for a particular xmake execution on the specified folder. After the first run, if you delete .xmake within ../build, .xmake directory will not appear again within ../build. However, if you delete the generated data within AppData/temp/xmake directory, the next xmake invocation generates .xmake within ../build.

I do not want any outputs generated within ../build (this example)

Project Configuration

toolchain("myclang") set_toolset("cc", "clang") set_toolset("ld", "clang") toolchain_end()

set_config("plat", "cross") set_toolchains("myclang") target("test") set_kind("binary") add_files("../src/*.c")

Additional Information and Error Logs

image

waruqi commented 1 month ago

see https://github.com/xmake-io/xmake/issues/3342

External working directory mode (new)

$ cd target_dir
$ xmake f -P ../build
$ xmake
LostTime76 commented 1 month ago

I have already tried that. It does not work. .xmake still appears next to xmake.lua in ../build

image

image

image

image

waruqi commented 1 month ago

It works for me.

ruki:test ruki$ tree .
.
โ”œโ”€โ”€ build
โ”‚ย ย  โ””โ”€โ”€ xmake.lua
โ”œโ”€โ”€ out
โ””โ”€โ”€ src
    โ””โ”€โ”€ main.cpp

3 directories, 2 files
ruki:test ruki$ ls -a ./build/
.       ..      xmake.lua
ruki:test ruki$ ls -a ./
.       ..      .gitignore  build       out     src
ruki:test ruki$ cd out/
ruki:out ruki$ xmake f -P ../build/
checking for platform ... macosx
checking for architecture ... x86_64
checking for Xcode directory ... /Applications/Xcode.app
checking for SDK version of Xcode for macosx (x86_64) ... 14.0
checking for Minimal target version of Xcode for macosx (x86_64) ... 14.0
ruki:out ruki$ xmake
[ 50%]: cache compiling.release ../src/main.cpp
[ 75%]: linking.release test
[100%]: build ok, spent 1.283s
ruki:out ruki$ ls -a ../build/
.       ..      xmake.lua
ruki:out ruki$ ls -a ../
.       ..      .gitignore  build       out     src
ruki:out ruki$ ls -a .
.   ..  .xmake  build
LostTime76 commented 1 month ago

Are you running on mac? My system is windows. I don't think I understand the justification "it works for me" when the example you gave would be on a different OS.

It does not work on windows. It is generating the erroneous .xmake next to xmake.lua

waruqi commented 1 month ago

It still works for me on windows.

PS C:\Users\wangrunqing\Downloads\tst> dir .

    ็›ฎๅฝ•: C:\Users\wangrunqing\Downloads\tst

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----          2024/8/7     12:12                build
d-----          2024/8/7     12:21                out
d-----          2024/8/7     12:08                src
-a----         2024/3/25      9:42             64 .gitignore

PS C:\Users\wangrunqing\Downloads\tst> dir .\build

    ็›ฎๅฝ•: C:\Users\wangrunqing\Downloads\tst\build

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----          2024/8/7     12:09           1964 xmake.lua

PS C:\Users\wangrunqing\Downloads\tst> dir .\out
PS C:\Users\wangrunqing\Downloads\tst> cd out
PS C:\Users\wangrunqing\Downloads\tst\out> xmake f -P ..\build
checking for platform ... windows
checking for architecture ... x64
checking for Microsoft Visual Studio (x64) version ... 2022
checking for Microsoft C/C++ Compiler (x64) version ... 19.41.33923
PS C:\Users\wangrunqing\Downloads\tst\out> xmake
[ 50%]: compiling.release ..\src\main.cpp
[ 75%]: linking.release tst.exe
[100%]: build ok, spent 1.125s
PS C:\Users\wangrunqing\Downloads\tst\out> dir ..\build

    ็›ฎๅฝ•: C:\Users\wangrunqing\Downloads\tst\build

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----          2024/8/7     12:09           1964 xmake.lua

PS C:\Users\wangrunqing\Downloads\tst\out> dir .

    ็›ฎๅฝ•: C:\Users\wangrunqing\Downloads\tst\out

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----          2024/8/7     12:21                .xmake
d-----          2024/8/7     12:21                build