diff options
| author | ruki <[email protected]> | 2020-02-26 22:36:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-02-26 09:39:12 +0800 |
| commit | ad15bd3efa81795baf0b99f69c9150b1763647c2 (patch) | |
| tree | 64656a9ca5bee10e6370be5700880a0dacb06613 /core/src | |
| parent | 510eccaf9ff776077b75ae189ac850035c6d3680 (diff) | |
improve make install
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/xmake/machine.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index f8704ff7f..f086dd17f 100644 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -487,7 +487,6 @@ static tb_bool_t xm_machine_get_program_directory(xm_machine_t* machine, tb_char tb_char_t data[TB_PATH_MAXN] = {0}; if (tb_environment_first("XMAKE_PROGRAM_DIR", data, sizeof(data)) && tb_path_absolute(data, path, maxn)) { - // ok ok = tb_true; break; } @@ -495,19 +494,25 @@ static tb_bool_t xm_machine_get_program_directory(xm_machine_t* machine, tb_char // get it from program file path if (programfile) { - tb_size_t size = tb_strlcpy(data, programfile, sizeof(data)); - if (size < sizeof(data)) + // get the root directory + tb_char_t data[TB_PATH_MAXN]; + tb_char_t const* rootdir = tb_path_directory(programfile, data, sizeof(data)); + tb_assert_and_check_break(rootdir); + + // find the program (lua) directory + tb_size_t i; + tb_file_info_t info; + tb_char_t scriptpath[TB_PATH_MAXN]; + tb_char_t const* subdirs[] = {"", "../share/xmake"}; + for (i = 0; i < tb_arrayn(subdirs); i++) { - // get the directory - while (size-- > 0) + // get program directory + if (tb_path_absolute_to(rootdir, subdirs[i], path, maxn) && + tb_path_absolute_to(path, "core/_xmake_main.lua", scriptpath, sizeof(scriptpath)) && + tb_file_info(scriptpath, &info) && info.type == TB_FILE_TYPE_FILE) { - if (data[size] == '\\' || data[size] == '/') - { - data[size] = '\0'; - tb_strlcpy(path, data, maxn); - ok = tb_true; - break; - } + ok = tb_true; + break; } } } |
