diff options
| author | ruki <[email protected]> | 2020-05-09 00:56:57 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-08 23:41:42 +0800 |
| commit | e262531aaf602519e28860de672aeae78c2e5e26 (patch) | |
| tree | 2ed4f6903eebbb624c342226f01e2b9bc2c47dd5 | |
| parent | 08a0d875fdef05a5f9dab726d59d71b5750b9653 (diff) | |
support readlink for bsd file
| -rw-r--r-- | core/src/xmake/engine.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index 44a58cd06..76886b326 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -41,6 +41,21 @@ #endif /* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ +#if defined(TB_CONFIG_OS_LINUX) +# define XM_PROC_SELF_FILE "/proc/self/exe" +#elif defined(TB_CONFIG_OS_BSD) +# if defined(__FreeBSD__) +# define XM_PROC_SELF_FILE "/proc/curproc/file" +# elif defined(__NetBSD__) +# define XM_PROC_SELF_FILE "/proc/curproc/exe" +# else +# define XM_PROC_SELF_FILE "/proc/curproc/file" +# endif +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// * types */ @@ -467,9 +482,9 @@ static tb_size_t xm_engine_get_program_file(xm_engine_t* engine, tb_char_t* path tb_uint32_t bufsize = (tb_uint32_t)maxn; if (!_NSGetExecutablePath(path, &bufsize)) ok = tb_true; -#elif defined(TB_CONFIG_OS_LINUX) || defined(TB_CONFIG_OS_BSD) +#elif defined(XM_PROC_SELF_FILE) // get the executale file path as program directory - ssize_t size = readlink("/proc/self/exe", path, (size_t)maxn); + ssize_t size = readlink(XM_PROC_SELF_FILE, path, (size_t)maxn); if (size > 0 && size < maxn) { // end |
