1. 首页
  2. 编程语言
  3. C++ 
  4. window10下源码编译chromium

window10下源码编译chromium

上传者: 2020-07-29 06:50:35上传 PDF文件 122.92KB 热度 37次
断断续续下载chromium代码花了1周左右,代码约15G左右,其中遇到power shell的问题,遇到python的问题。最终编译花了11:30分。相比于Linux下的编译慢很多,系统运行的稳定性和速度也差很多。打算研究源码,一起分享。11/3/2018Checking out and Building Chromium for WindowsGet the codeFirst, configure gits git config --global user name "My Names git config --global user email "my-name@chromium. org''s git config --global core. autocrlf falses git config --global core filemode falses git configglobal branch. autosetuprebase alwaysCreate a chromium directory for the checkout and change to it (you can call this whatever you like and putit wherever you like, as long as the full path has no spaces)s mkdir chromium & cd chromiumRun the fetch tool from depot_tools to check out the code and its dependenciess fetch chromiumIf you don't want the full repo history, you can save a lot of time by adding the --no-history flag tofetchExpect the command to take 30 minutes on even a fast connection, and many hours on slower onesWhen fetch completes, it will have created a hidden gclient file and a directory called src in theworking directory. The remaining instructions assume you have switched to the src directorys cd srcOptional You can also install API keys if you want your build to talk to some Google services, but this is notnecessary for most development and testing purposes.Setting up the buildChromium uses Ninja as its main build tool along with a tool called Gn to generate ninja files. You cancreate any number of build directories with different configurations. To create a build directorys gn gen out/DefaultYou only have to run this once for each new build directory, Ninja will update the build files asneededYou can replace Default with another name, but it should be a subdirectory of outFor other build arguments including release settings, see gn build configuration. the default will bea debug component build matching the current host operating system and CPUFor more info on GN, run gn help on the command line or read the quick start guidehttps://chromium.googlesource.com/chromium/src/+/head/docs/windowsbuildinstructionsmd3/811/3/2018Checking out and Building Chromium for WindowsUsing the visual Studio IDEIf you want to use the visual Studio IDE, use the --ide command line argument to gn gen when yougenerate your output directory (as described on the get the code pages gn gen --ide=vs out\ Defaults deveny out Default\all. slnGN will produce a file all. sln in your build directory. It will internally use ninja to compile while stillallowing most IDE functions to work (there is no native visual Studio compilation mode). If you manuallyrun " gen"again you will need to resupply this argument, but normally gn will keep the build and IdE filesup to date automatically when you buildThe generated solution will contain several thousand projects and will be very slow to load. Use the -filters argument to restrict generating project files for only the code you're interested in. Although thiswill also limit what files appear in the project explorer, debugging will still work and you can set breakpointsin files that you open manually. a minimal solution that will let you compile and run Chrome in the Ide butwill not show any source files iss gn gen --ide=vs --filters=//chrome --no-deps out\ DefaultYou can selectively add other directories you care about to the filter like sofilters=// chrome; //third-party /WebKit/*;//gpu/*There are other options for controlling how the solution is generated, run gn help gen for the currentdocumentationy default when you start debugging in Visual Studio the debugger will only attach to the main browserprocess. To debug all of Chrome, install Microsoft's Child Process Debugging Power Tool. You will also needto run visual Studio as administrator, or it will silently fail to attach to some of Chromes child processesIt is also possible to debug and develop Chrome in visual Studio without a solution file. Simply "open "yourchrome. exe binary with File->Open->Project/Solution, or from a Visual Studio command promptlike so: devenv debugexe out\ Debug\chrome. exe . Many of visual Studio'scode editing features will not work in this configuration, but by installing the vs Chromium Visual StudioExtension you can get the source code to appear in the solution explorer window along with other usefulfeatures such as code searchFaster buildsReduce file system overhead by excluding build directories from antivirus and indexing software.Store the build tree on a fast disk(preferably SSD)The more cores the better(20+ is not excessive) and lots of ram is needed (64 gb is not excessivewhen you create your output directory (gn args out/Default)or on the gn gen command line tThere are some gn flags that can improve build speeds. You can specify these in the editor that appegen out/Default --args=is_ component_build true is_debug true ") Some helpfulsettings to consider using include:https://chromium.googlesource.com/chromium/src/+/head/docs/windowsbuildinstructionsmd11/3/2018Checking out and Building Chromium for Windowsuse_jumbo_ build true-experimental Jumbo/unity buildsis_component_build true-this uses more, smaller DLLs, and incremental linkinge enable_nacl false- this disables Native Client which is usually not needed for local buildse target_cpu =X86-X86 builds are slightly faster than x64 builds and support incrementainking for more targets. note that if you set this but don't' set enable_nacl -false then build timesmay get worseremove_webcore_debug_symbols = true-turn off source-level debugging for blink to reducebuild times, appropriate if you don 't plan to debug blinkIn order to speed up linking you can set symbol_level =l-this option reduces the work the linker hasto do but when this option is set you cannot do source-level debugging. Switching from symbol_level2(the default)to symbol_level =1 requires recompiling everythingIn addition, Google employees should use goma, a distributed compilation system. Detailed information isavailable internally but the relevant gn arg iso use goma = trueTo get any benefit from goma it is important to pass a large -j value to ninja. a good default is10*numCores to 20*numCores. If you run autoninja then it will automatically pass an appropriate -j valueto ninja for goma or nots autoninja-c out\ Default chromeWhen invoking ninja specify 'chrome' as the target to avoid building all test binaries as wellStill, builds will take many hours on many machinesWhy is my build slow?Many things can make builds slow, with Windows Defender slowing process startups being a frequentculprit. Have you ensured that the entire Chromium src directory is excluded from antivirus scanning(olGoogle machines this means putting it in a src directory in the root of a drive)? Have you tried thedifferent settings listed above, including different link settings and - values? Have you asked on thechromium-dev mailing list to see if your build is slower than expected for your machines specifications?The next step is to gather some data. There are several options Setting NINJA_ STatus lets you configureNinja's output so that, for instance, you can see how many processes are running at any given time, howlong the build has been running, etc, as shown heres set NINJA_STATUS=[%r processes, %f/9t a 960/s: %es Is autoninja -c out\De fault baseninja: Entering directory out\ Default'[1 processes, 86/86@2.7/s: 31.785s LINK(DLL) base.dll base. dll. lib base. dll. pdbIn addition, if you set the NiNJA_ SUMMARIZE_BUILD environment variable to 1 then autoninja will print abuild performance summary when the build completes, showing the slowest build steps and build-steptypes, as shown herehttps://chromium.googlesource.com/chromium/src/+/head/docs/windowsbuildinstructionsmd5/811/3/2018Checking out and Building Chromium for Windowss set NINJA SUMMARIZE BUILD=1s autoninja-c out\ Default baseLongest build steps:1.2 weighted s to build base. dll, base. dll. lib, base. dll. pdb(1.2 s CPu ti8.5 weighted s to build obj/ base /base/base_jumbo_38.obj (30.1 s CPU time)Time by build-step type:1.2 s wei ghted time to generate 1 PEFile (linking) files (1.2 s CPU time)30.3 s wei ghted time to generate 45 .obj files (688.8 s CPU time)31.8 s wei ghted time(693.8 s CPU time, 21.8x parallelism)86 build steps completed, average of 2.71/sYou can also generate these reports by manually running the script after a builds python depot_ tools\post build_ninja_ summary. py -c out\ DefaultYou can also get a visual report of the build performance with ninjatracing. This converts the ninja_log fileinto a json file which can be loaded into chrome: //tracings python ninjatracing out\Default\ ninja_log >build jsonFinally, Ninja can report on its own overhead which can be helpful if, for instance, process creation ismaking builds slow, perhaps due to antivirus interference due to clang-cl not being in an excludeddirectorys autoninja -d stats -C out\Default basemetriccount avg (us)total(msninja parse35551539.45472,6canonicalize str13839320,012.7canonicalize path14023490.611.2lookup node13982450.08.1ninja_log load118.0⊙.2ninja_deps load67.5node stat251629.674.4defile load1132.02.3started883568.13⊙8.7FinishCommand871670.9145.4CLParser:: Parse451889.185.0Build chromiumBuild Chromium (the"chrome"target)with Ninja using the commands autoninja -c out Default chromehttps://chromium.googlesource.com/chromium/src/+/head/docs/windowsbuildinstructionsmd6/811/3/2018Checking out and Building Chromium for Windowsautoninja is a wrapper that automatically provides optimal values for the arguments passed to ninjaYou can get a list of all of the other build targets from gn by running gn ls out/Default from thecommand line To compile one, pass to Ninja the gn label with no preceding"/"(so for//chrome/test: unit_tests use ninja-C out/Default chrome/test unit_testsRun chromiumOnce it is built, you can simply run the browser:s out\ Default\chrome.exe(The".exe"suffix in the command is actually optionalRunning test targetsYou can run the tests in the same way. You can also limit which tests are run using the --gtest filterarg, e. gs out\ Defaultlunit_ tests. exe --gtest_filter="PushclientTest*rYou can find out more about Google Test at its GitHub pageUpdate your checkoutTo update an existing checkout, you can runs git rebase-updates gclient syncThe first command updates the primary Chromium source repository and rebases any of your localbranches on top of tip-of-tree (aka the Git branch origin/master ) If you don't want to use this script,you can also just use git pull or other common git commands to update the repo.The second command syncs the subrepositories to the appropriate versions and re-runs the hooks asneededPowered by Gitiles Privacyhttps://chromium.googlesource.com/chromium/src/+/head/docs/windowsbuildinstructionsmd7/811/3/2018Checking out and Building Chromium for Windowshttps://chromium.googlesource.com/chromium/src/+/head/docs/windowsbuildinstructionsmd8/8
下载地址
用户评论