From e6d512eb838215d6028d4042591a8fec411f207b Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Wed, 20 Aug 2025 22:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E4=B8=BA=20`XY=5FBu?= =?UTF-8?q?ild=5FOn=5Fxx`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/03-为什么拒绝使用代码格式化工具.md | 2 +- lib/xy.h | 19 +++++++++++++------ src/framework/core.c | 8 ++++---- src/recipe/lang/Python/uv.c | 2 +- src/recipe/lang/Rust/rustup.c | 2 +- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/doc/03-为什么拒绝使用代码格式化工具.md b/doc/03-为什么拒绝使用代码格式化工具.md index a258066..08991d7 100644 --- a/doc/03-为什么拒绝使用代码格式化工具.md +++ b/doc/03-为什么拒绝使用代码格式化工具.md @@ -70,7 +70,7 @@ if (!matched) matched = iterate_menu (chsrc_wr_menu, input, &target_tmp); ```c #ifdef _WIN32 - #define XY_On_Windows 1 + #define XY_Build_On_Windows 1 #define xy_on_windows true #ifdef XY_DEBUG #define xy_debug_mode 1 diff --git a/lib/xy.h b/lib/xy.h index 97f3e75..af6d42f 100644 --- a/lib/xy.h +++ b/lib/xy.h @@ -62,7 +62,8 @@ bool xy_enable_color = true; // #define NDEBUG #ifdef _WIN32 - #define XY_On_Windows 1 + #define XY_Build_On_Windows 1 + #define xy_on_windows true #define xy_on_linux false #define xy_on_macos false @@ -73,7 +74,9 @@ bool xy_enable_color = true; #define xy_use_utf8() SetConsoleOutputCP (65001) #elif defined(__linux__) || defined(__linux) - #define XY_On_Linux 1 + #define XY_Build_On_Linux 1 + #define XY_Build_On_Unix 1 + #define xy_on_windows false #define xy_on_linux true #define xy_on_macos false @@ -82,7 +85,9 @@ bool xy_enable_color = true; #define xy_use_utf8() #elif defined(__APPLE__) - #define XY_On_macOS 1 + #define XY_Build_On_macOS 1 + #define XY_Build_On_Unix 1 + #define xy_on_windows false #define xy_on_linux false #define xy_on_macos true @@ -91,7 +96,9 @@ bool xy_enable_color = true; #define xy_use_utf8() #elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) - #define XY_On_BSD 1 + #define XY_Build_On_BSD 1 + #define XY_Build_On_Unix 1 + #define xy_on_windows false #define xy_on_linux false #define xy_on_macos false @@ -916,7 +923,7 @@ _xy_os_home () static char * _xy_win_documents () { -#ifdef XY_On_Windows +#ifdef XY_Build_On_Windows char documents_path[MAX_PATH]; HRESULT result = SHGetFolderPathA (NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, documents_path); @@ -1009,7 +1016,7 @@ xy_dir_exist (const char *path) if (xy_on_windows) { -#ifdef XY_On_Windows +#ifdef XY_Build_On_Windows // 也可以用 opendir() #include DWORD attr = GetFileAttributesA (dir); diff --git a/src/framework/core.c b/src/framework/core.c index dcfae7c..360d523 100644 --- a/src/framework/core.c +++ b/src/framework/core.c @@ -1338,7 +1338,7 @@ chsrc_run_as_a_service (const char *cmd) FILE * chsrc_make_tmpfile (char *filename, char *postfix, bool loud, char **tmpfilename) { -#ifdef XY_On_Windows +#ifdef XY_Build_On_Windows /** * Windows 上没有 mkstemps(),只有 mkstemp() 和 _mktemp_s(),这后两者效果是等价的,只不过传参不同, * 这意味着我们无法给一个文件名后缀(postfix),只能生成一个临时文件名 @@ -1489,7 +1489,7 @@ chsrc_view_env (const char *var1, ...) bool first = true; while (var) { -#ifdef XY_On_Windows +#ifdef XY_Build_On_Windows if (first) { cmd = xy_strcat (3, "set ", var, " "); @@ -1757,7 +1757,7 @@ chsrc_get_cpuarch () char *ret; char *msg; -#if XY_On_Windows +#if XY_Build_On_Windows SYSTEM_INFO info; GetSystemInfo (&info); WORD num = info.wProcessorArchitecture; @@ -1810,7 +1810,7 @@ chsrc_get_cpucore () { int cores = 2; -#if XY_On_Windows +#if XY_Build_On_Windows SYSTEM_INFO info; GetSystemInfo (&info); DWORD num = info.dwNumberOfProcessors; diff --git a/src/recipe/lang/Python/uv.c b/src/recipe/lang/Python/uv.c index a8dff93..2a47c0c 100644 --- a/src/recipe/lang/Python/uv.c +++ b/src/recipe/lang/Python/uv.c @@ -125,7 +125,7 @@ pl_python_uv_setsrc (char *option) const char *source_content = xy_str_gsub (RAWSTR_pl_python_uv_config_source_content, "@url@", source.url); -#if defined(XY_On_macOS) || defined(XY_On_BSD) +#if defined(XY_Build_On_macOS) || defined(XY_Build_On_BSD) char *sed_cmd = "sed -i '' "; #else char *sed_cmd = "sed -i "; diff --git a/src/recipe/lang/Rust/rustup.c b/src/recipe/lang/Rust/rustup.c index 7f9fbe2..cba0bf4 100644 --- a/src/recipe/lang/Rust/rustup.c +++ b/src/recipe/lang/Rust/rustup.c @@ -62,7 +62,7 @@ pl_rust_rustup_setsrc (char *option) { use_this_source(pl_rust_rustup); -#ifdef XY_On_Windows +#ifdef XY_Build_On_Windows char *cmd1 = xy_strcat (3, "setx RUSTUP_DIST_SERVER \"", source.url, "\""); char *cmd2 = xy_strcat (3, "setx RUSTUP_UPDATE_ROOT \"", source.url, "/rustup\"");