Why Do We Need Gyp?
Total Page:16
File Type:pdf, Size:1020Kb
Why do we need gyp? • Gyp stands for “Generate your project” • Started from Xcode • Gyp was invented for Chromium • It is important that IDE is part of workflow • This is ALMOST json (comment are hashes) Gyp workflow ● Change gyp file ● Run glient sync ● Reload IDE Gyp files organization ● One gyp file per component ● Chrome and webkit are quite big - exception Gyp build directory ● build/all.gyp – whole configuration ● build/common.gypi – added to many files ● build/external_code.gypi – for third party ● build/linux/system.gyp - for linux ● build/win/system.gyp - for win ● chrome.gyp - main entry point gclient runhook —force What happens when I run “gclient runhook —force” ● For Windows 1) Each gyp файл generate sln 2) Each target generates vsproj ● For Mac 1) Each gyp generates .xcodeproj ● For Linux 1) generates scons files 2) Theoretically there is -f to build linux files on mac, windows and vise versa Gyp file content { ● 'targets': [ ● { ● # Note this library is missing an implementation for the video capture. ● # Targets must link with either 'video_capture_module_impl' or ● # 'video_capture_module_internal_impl' depending on whether they want to ● # use the internal capturer. ● 'target_name': 'video_capture_module', ● 'type': 'static_library', ● 'dependencies': [ ● 'webrtc_utility', ● '<(webrtc_root)/common_video/common_video.gyp:common_video', ● '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', ● ], ● 'sources': [ ● 'device_info_impl.cc', ● 'device_info_impl.h', ● 'include/video_capture.h', ● 'include/video_capture_defines.h', ● 'include/video_capture_factory.h', ● 'video_capture_config.h', ● 'video_capture_delay.h', ● 'video_capture_factory.cc', ● 'video_capture_impl.cc', ● 'video_capture_impl.h', ● ], ● }, Gyp file content (2) Variables ● Used in condition blocks ● chromium_code=1 – addes additional checks ● Os variable is setted by gyp Includes ● Gyp includes ● You need to include build/common.gypi ● Includes overrides file options, so they should be in the begin Target_defaults ● Dictionary of settings ● Applied to all targets Targets ● Main part of gyp files ● Also set of dictionaries Skeleton of targets ● target_name – name of executable ● type - (executable, shared_library, static_library, …). None – is also possible (custom build rule) ● msvs_guid – temporary solution for VS ● Dependencies – dependencies for other targets ● sources – pathes to files Using gyp in Chromium ● By default we use ninja build system ● We can use Xcode as build system but this will be much slower. But this should work GYP_GENERATORS=xcode GYP_DEFINES=mac_sdk=10.8 ./build/gyp_chromium ● Much better example is use xcode as IDE and ninja for build GYP_GENERATORS=ninja,xcode-ninja GYP_DEFINES=mac_sdk=10.8 ./build/gyp_chromium ● After this you can open project open ./build/all.ninja.xcworkspace Gyp generators ● Using gyp we can generate various projects ● Full list can be seen here https://chromium.googlesource.com/external/gyp.git/+/master/pylib/gyp/generator/ ● For us, following is importrant 1) cmake.py - cmake 2) eclipse.py - eclipse 3) make.py - make 4) msvs.py - vs project 5) ninja.py - ninja project 6) xcode.py - xcode project ● But unit tests exists only for three options => another can be unstable 1) msvs 2) ninja 3) xcode Cmake ● Generates ./out/Debug/CMakeLists.txt ./out/Release/CMakeLists.txt Eclipse ● Creates ./out/Debug/eclipse-cdt-settings.xml ./out/Release/eclipse-cdt-settings.xml ● And later you need File - Import - C/C++ project settings Make ● non-recursive make ● Currenty turned off in Chromium Msvs ● Generates ./build/all.sln Ninja ● Generates ./out/Debug/build.ninja ./out/Release/build.ninja Xcode ● Generates ./build/all.ninja.xcworkspace .