mirror of
https://github.com/RubyMetric/chsrc
synced 2025-09-09 02:26:43 +08:00
重命名为 XY_Build_On_xx
This commit is contained in:
parent
9d7543b681
commit
e6d512eb83
@ -70,7 +70,7 @@ if (!matched) matched = iterate_menu (chsrc_wr_menu, input, &target_tmp);
|
|||||||
|
|
||||||
```c
|
```c
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define XY_On_Windows 1
|
#define XY_Build_On_Windows 1
|
||||||
#define xy_on_windows true
|
#define xy_on_windows true
|
||||||
#ifdef XY_DEBUG
|
#ifdef XY_DEBUG
|
||||||
#define xy_debug_mode 1
|
#define xy_debug_mode 1
|
||||||
|
19
lib/xy.h
19
lib/xy.h
@ -62,7 +62,8 @@ bool xy_enable_color = true;
|
|||||||
// #define NDEBUG
|
// #define NDEBUG
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define XY_On_Windows 1
|
#define XY_Build_On_Windows 1
|
||||||
|
|
||||||
#define xy_on_windows true
|
#define xy_on_windows true
|
||||||
#define xy_on_linux false
|
#define xy_on_linux false
|
||||||
#define xy_on_macos false
|
#define xy_on_macos false
|
||||||
@ -73,7 +74,9 @@ bool xy_enable_color = true;
|
|||||||
#define xy_use_utf8() SetConsoleOutputCP (65001)
|
#define xy_use_utf8() SetConsoleOutputCP (65001)
|
||||||
|
|
||||||
#elif defined(__linux__) || defined(__linux)
|
#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_windows false
|
||||||
#define xy_on_linux true
|
#define xy_on_linux true
|
||||||
#define xy_on_macos false
|
#define xy_on_macos false
|
||||||
@ -82,7 +85,9 @@ bool xy_enable_color = true;
|
|||||||
#define xy_use_utf8()
|
#define xy_use_utf8()
|
||||||
|
|
||||||
#elif defined(__APPLE__)
|
#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_windows false
|
||||||
#define xy_on_linux false
|
#define xy_on_linux false
|
||||||
#define xy_on_macos true
|
#define xy_on_macos true
|
||||||
@ -91,7 +96,9 @@ bool xy_enable_color = true;
|
|||||||
#define xy_use_utf8()
|
#define xy_use_utf8()
|
||||||
|
|
||||||
#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
|
#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_windows false
|
||||||
#define xy_on_linux false
|
#define xy_on_linux false
|
||||||
#define xy_on_macos false
|
#define xy_on_macos false
|
||||||
@ -916,7 +923,7 @@ _xy_os_home ()
|
|||||||
static char *
|
static char *
|
||||||
_xy_win_documents ()
|
_xy_win_documents ()
|
||||||
{
|
{
|
||||||
#ifdef XY_On_Windows
|
#ifdef XY_Build_On_Windows
|
||||||
char documents_path[MAX_PATH];
|
char documents_path[MAX_PATH];
|
||||||
HRESULT result = SHGetFolderPathA (NULL, CSIDL_MYDOCUMENTS, NULL,
|
HRESULT result = SHGetFolderPathA (NULL, CSIDL_MYDOCUMENTS, NULL,
|
||||||
SHGFP_TYPE_CURRENT, documents_path);
|
SHGFP_TYPE_CURRENT, documents_path);
|
||||||
@ -1009,7 +1016,7 @@ xy_dir_exist (const char *path)
|
|||||||
|
|
||||||
if (xy_on_windows)
|
if (xy_on_windows)
|
||||||
{
|
{
|
||||||
#ifdef XY_On_Windows
|
#ifdef XY_Build_On_Windows
|
||||||
// 也可以用 opendir() #include <dirent.h>
|
// 也可以用 opendir() #include <dirent.h>
|
||||||
DWORD attr = GetFileAttributesA (dir);
|
DWORD attr = GetFileAttributesA (dir);
|
||||||
|
|
||||||
|
@ -1338,7 +1338,7 @@ chsrc_run_as_a_service (const char *cmd)
|
|||||||
FILE *
|
FILE *
|
||||||
chsrc_make_tmpfile (char *filename, char *postfix, bool loud, char **tmpfilename)
|
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(),这后两者效果是等价的,只不过传参不同,
|
* Windows 上没有 mkstemps(),只有 mkstemp() 和 _mktemp_s(),这后两者效果是等价的,只不过传参不同,
|
||||||
* 这意味着我们无法给一个文件名后缀(postfix),只能生成一个临时文件名
|
* 这意味着我们无法给一个文件名后缀(postfix),只能生成一个临时文件名
|
||||||
@ -1489,7 +1489,7 @@ chsrc_view_env (const char *var1, ...)
|
|||||||
bool first = true;
|
bool first = true;
|
||||||
while (var)
|
while (var)
|
||||||
{
|
{
|
||||||
#ifdef XY_On_Windows
|
#ifdef XY_Build_On_Windows
|
||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
cmd = xy_strcat (3, "set ", var, " ");
|
cmd = xy_strcat (3, "set ", var, " ");
|
||||||
@ -1757,7 +1757,7 @@ chsrc_get_cpuarch ()
|
|||||||
char *ret;
|
char *ret;
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
||||||
#if XY_On_Windows
|
#if XY_Build_On_Windows
|
||||||
SYSTEM_INFO info;
|
SYSTEM_INFO info;
|
||||||
GetSystemInfo (&info);
|
GetSystemInfo (&info);
|
||||||
WORD num = info.wProcessorArchitecture;
|
WORD num = info.wProcessorArchitecture;
|
||||||
@ -1810,7 +1810,7 @@ chsrc_get_cpucore ()
|
|||||||
{
|
{
|
||||||
int cores = 2;
|
int cores = 2;
|
||||||
|
|
||||||
#if XY_On_Windows
|
#if XY_Build_On_Windows
|
||||||
SYSTEM_INFO info;
|
SYSTEM_INFO info;
|
||||||
GetSystemInfo (&info);
|
GetSystemInfo (&info);
|
||||||
DWORD num = info.dwNumberOfProcessors;
|
DWORD num = info.dwNumberOfProcessors;
|
||||||
|
@ -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);
|
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 '' ";
|
char *sed_cmd = "sed -i '' ";
|
||||||
#else
|
#else
|
||||||
char *sed_cmd = "sed -i ";
|
char *sed_cmd = "sed -i ";
|
||||||
|
@ -62,7 +62,7 @@ pl_rust_rustup_setsrc (char *option)
|
|||||||
{
|
{
|
||||||
use_this_source(pl_rust_rustup);
|
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 *cmd1 = xy_strcat (3, "setx RUSTUP_DIST_SERVER \"", source.url, "\"");
|
||||||
char *cmd2 = xy_strcat (3, "setx RUSTUP_UPDATE_ROOT \"", source.url, "/rustup\"");
|
char *cmd2 = xy_strcat (3, "setx RUSTUP_UPDATE_ROOT \"", source.url, "/rustup\"");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user