Skip to content

Commit e6affab

Browse files
committed
support openbsd
1 parent 1635169 commit e6affab

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Diff for: CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
### Changes
1111

1212
* [#2925](https://github.com/xmake-io/xmake/issues/2925): Improve doxygen plugin
13+
* [#2948](https://github.com/xmake-io/xmake/issues/2948): Support OpenBSD
1314

1415
## v2.7.2
1516

@@ -1421,6 +1422,7 @@
14211422
### 改进
14221423

14231424
* [#2925](https://github.com/xmake-io/xmake/issues/2925): 改进 doxygen 插件
1425+
* [#2948](https://github.com/xmake-io/xmake/issues/2948): 支持 OpenBSD
14241426

14251427
## v2.7.2
14261428

Diff for: core/src/xmake/engine.c

+26-1
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,13 @@ static tb_size_t xm_engine_get_program_file(xm_engine_t* engine, tb_char_t* path
619619
tb_bool_t ok = tb_false;
620620
do
621621
{
622+
// get it from the environment variable first
623+
if (tb_environment_first("XMAKE_PROGRAM_FILE", path, maxn) && tb_file_info(path, tb_null))
624+
{
625+
ok = tb_true;
626+
break;
627+
}
628+
622629
#if defined(TB_CONFIG_OS_WINDOWS)
623630
// get the executale file path as program directory
624631
tb_wchar_t buf[TB_PATH_MAXN] = {0};
@@ -647,7 +654,8 @@ static tb_size_t xm_engine_get_program_file(xm_engine_t* engine, tb_char_t* path
647654
tb_uint32_t bufsize = (tb_uint32_t)maxn;
648655
if (!_NSGetExecutablePath(path, &bufsize))
649656
ok = tb_true;
650-
#elif defined(TB_CONFIG_OS_BSD)
657+
#elif defined(TB_CONFIG_OS_BSD) && defined(KERN_PROC_PATHNAME)
658+
// only for freebsd, https://github.com/xmake-io/xmake/issues/2948
651659
tb_int_t mib[4]; mib[0] = CTL_KERN; mib[1] = KERN_PROC; mib[2] = KERN_PROC_PATHNAME; mib[3] = -1;
652660
size_t size = maxn;
653661
if (sysctl(mib, 4, path, &size, tb_null, 0) == 0 && size < maxn)
@@ -663,6 +671,23 @@ static tb_size_t xm_engine_get_program_file(xm_engine_t* engine, tb_char_t* path
663671
path[size] = '\0';
664672
ok = tb_true;
665673
}
674+
#else
675+
static tb_char_t const* s_paths[] =
676+
{
677+
"~/.local/bin/xmake",
678+
"/usr/local/bin/xmake",
679+
"/usr/bin/xmake"
680+
};
681+
for (tb_size_t i = 0; i < tb_arrayn(s_paths); i++)
682+
{
683+
tb_char_t const* p = s_paths[i];
684+
if (tb_file_info(p, tb_null))
685+
{
686+
tb_strlcpy(path, p, maxn);
687+
ok = tb_true;
688+
break;
689+
}
690+
}
666691
#endif
667692

668693
} while (0);

0 commit comments

Comments
 (0)