Skip to content
This repository was archived by the owner on Dec 10, 2022. It is now read-only.

Commit 275406a

Browse files
committed
fix mac-clt installation
1 parent b2c6159 commit 275406a

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 更新日志 Change Log
22

33
## \[3.1.1\]
4-
*Pending*
4+
*2021.9.9*
55

66
- 优化了 macOS 下的外置终端脚本;
77
- 增加 Windows 下选择 32 位编译器的警告。

src/cli.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ void preprocessOptions(const po::options_description& desc) {
5656
checkUpdate();
5757
std::exit(0);
5858
}
59+
#ifdef MACOS
60+
if (!options.NoInstallClt) {
61+
if (!fs::exists("/Library/Developer/CommandLineTools")) {
62+
LOG_WRN(
63+
"未安装 Xcode Command Line "
64+
"Tools,将进行安装。这可能需要一段时间,请按照系统提示操作。安装完成后,再次启动本"
65+
"工具以进行配置。");
66+
boost::process::system("xcode-select --install");
67+
std::exit(1);
68+
} else {
69+
LOG_INF("检测到已安装的 Xcode Command Line Tools。");
70+
}
71+
}
72+
#endif
5973
}
6074

6175
template <typename T>
@@ -326,24 +340,6 @@ void runCli(const Environment& env) {
326340
}
327341
options.MingwPath = pInfo->Path;
328342
#else
329-
#ifdef MACOS
330-
if (!options.NoInstallClt) {
331-
if (!fs::exists("/Library/Developer/CommandLineTools")) {
332-
LOG_WRN(
333-
"未安装 Xcode Command Line "
334-
"Tools,将进行安装。这可能需要一段时间。请按照系统提示操作。");
335-
int retVal{boost::process::system("xcode-select --install")};
336-
if (retVal != 0) {
337-
LOG_ERR("安装失败。请手动安装编译器,或添加 -no-install-clt 参数禁用安装过程。");
338-
} else {
339-
LOG_INF("安装成功。");
340-
}
341-
options.Compiler = options.Language == LanguageType::Cpp ? CXX_COMPILER : C_COMPILER;
342-
} else {
343-
LOG_INF("检测到已安装的 Xcode Command Line Tools。");
344-
}
345-
}
346-
#endif
347343
if (options.Compiler.empty()) {
348344
auto r{std::find_if(compilers.begin(), compilers.end(),
349345
[](const CompilerInfo& c) { return c.langType == options.Language; })};

0 commit comments

Comments
 (0)