-
Notifications
You must be signed in to change notification settings - Fork 563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try to Use Ninja to Speed Up Build #666
Conversation
在 ci 中启用 Ninja 是合理的 但是在 Makefile 将 Ninja 设为 cmake 默认生成, 则要求开发环境中必须要安装 Ninja,是否考虑将这个能力作为一个配置项呢 |
@zhaozg 确实!你想的很周到,应该允许开发者自由选择。CMake 应该可以通过设定环境变量来选择构建文件生成器,我再完善一下,感谢提议。 不过我认为关键矛盾其实还是因为 ninja 即使在今天用得越来越多,很多系统的提供的默认开发环境还是不提供 ninja。用 ninja 必须要求环境里装 ninja,那其实用 make 其实也必须要求环境里装 make 嘛 ...... |
我认为librime这个make套cmake再make/ninja是不合理的,最外层的make不跨平台,而且在这个PR之前传-j也不会让内层make并行 |
没有特殊情况,一般不需要手动传 Makefile(还有 Ninja 的 build.ninja)本质就是一个基于规则/任务的脚本。用它去控制每个构建任务其实并没有什么不合理。 |
可我在master branch 我想表达的是,@zhaozg 的需求其实直接调cmake就好了,用不用ninja/带不带glog之类的随便控制,不然要么把最外层的Makefile加一堆条目,要么得从Makefile往cmake传一堆参数 |
@eagleoflqj 看起来我误会了什么,应该是要手动传 |
d3cec19
to
6b15b89
Compare
38d7f4f
to
efcaf18
Compare
efcaf18
to
709bbae
Compare
d945cbd
to
4a715d0
Compare
This is required by non-Visual-Studio makefile generator
4a715d0
to
c3ba2c3
Compare
The program will not be put in the <build_config> dir if we don't set the makefile generator as Visual Studio stuffs.
@lotem This PR is ready for review. |
It's better that do rebase and combine to ONE commit, will get a clear commit history and avoid many intermediate commit. |
The CI seems to be malfunctioning, I'd like to close the PR, reorganize the commits then reopen. |
set CMAKE_GENERATOR="Visual Studio 15 2017" | ||
set PLATFORM_TOOLSET=v141_xp | ||
) else ( | ||
set "VSVEROPT=-version [15.0^,16.0^)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the else-block do? Why is it on the defined CMAKE_GENERATOR
branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If CMAKE_GENERATOR
is defined outside the scripts, it may not be Visual Studio xx xxxx
. To preserve the original settings, I split out a else-block for non-Visual-Studio generator to run a script which call vswhere.exe
to find the Visual Studio's install location and call vcvarsall.bat
to set almost all environment variables we need.
In a word, if one don't specify CMAKE_GENERATOR
before calling env.bat
and build.bat
to build, it will use our original settings to build, otherwise the scripts will find and set everything we need and build with the specified generator.
@@ -6,10 +6,18 @@ rem REQUIRED: path to Boost source directory | |||
if not defined BOOST_ROOT set BOOST_ROOT=%RIME_ROOT%\deps\boost_1_78_0 | |||
|
|||
rem architecture, Visual Studio version and platform toolset | |||
set ARCH=Win32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these envars are not set in the else-branch. That's probably not okay because build.bat
uses these variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lotem These envars like ARCH
here only make sense when CMAKE_GENERATOR
is something like Visual Studio xx xxxx
. I think there are enough refactors in `build.bat to adopt these changes.
set CMAKE_GENERATOR="Visual Studio 16 2019" | ||
set PLATFORM_TOOLSET=v142 | ||
) else ( | ||
set "VSVEROPT=-version [16.0^,17.0^)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about creating a separate env.bat
file with the else branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lotem No need actually. Else-block plays the same role with if-block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this script do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lotem To find where Visual Studio installed in and set some envars we need.
-DBOOST_ROOT="$(BOOST_ROOT)" | ||
endif | ||
|
||
# https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_SYSROOT.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines repeats scripts in xcode.mk
. Can Makefile
replace xcode.mk
after this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lotem I think the answer is yes. We can merge Makefile
and xcode.mk
since the latter just specify CMAKE_GENERATOR
as Xcode and nothing else is different with the former.
Pull request
Issue tracker
Fixes will automatically close the related issue
Fixes # N/A
Feature
Describe feature of pull request
This PR is to use ninja to build the stuffs on Linux and macOS to speed up the build.
Unit test
Manual test
Code Review
Additional Info