OLD | NEW |
(Empty) | |
| 1 # Getting Started |
| 2 |
| 3 How to get and build the libyuv code. |
| 4 |
| 5 ## Pre-requisites |
| 6 |
| 7 You'll need to have depot tools installed: https://www.chromium.org/developers/h
ow-tos/install-depot-tools |
| 8 Refer to chromium instructions for each platform for other prerequisites. |
| 9 |
| 10 ## Getting the Code |
| 11 |
| 12 Create a working directory, enter it, and run: |
| 13 |
| 14 gclient config https://chromium.googlesource.com/libyuv/libyuv |
| 15 gclient sync |
| 16 |
| 17 |
| 18 Then you'll get a .gclient file like: |
| 19 |
| 20 solutions = [ |
| 21 { "name" : "libyuv", |
| 22 "url" : "https://chromium.googlesource.com/libyuv/libyuv", |
| 23 "deps_file" : "DEPS", |
| 24 "managed" : True, |
| 25 "custom_deps" : { |
| 26 }, |
| 27 "safesync_url": "", |
| 28 }, |
| 29 ]; |
| 30 |
| 31 |
| 32 For iOS add `;target_os=['ios'];` to your OSX .gclient and run `GYP_DEFINES="OS=
ios" gclient sync.` |
| 33 |
| 34 Browse the Git reprository: https://chromium.googlesource.com/libyuv/libyuv/+/ma
ster |
| 35 |
| 36 ### Android |
| 37 For Android add `;target_os=['android'];` to your Linux .gclient |
| 38 |
| 39 |
| 40 solutions = [ |
| 41 { "name" : "libyuv", |
| 42 "url" : "https://chromium.googlesource.com/libyuv/libyuv", |
| 43 "deps_file" : "DEPS", |
| 44 "managed" : True, |
| 45 "custom_deps" : { |
| 46 }, |
| 47 "safesync_url": "", |
| 48 }, |
| 49 ] |
| 50 target_os = ["android", "unix"] |
| 51 |
| 52 Then run: |
| 53 |
| 54 export GYP_DEFINES="OS=android" |
| 55 gclient sync |
| 56 |
| 57 For Windows the gclient sync must be done from an Administrator command prompt. |
| 58 |
| 59 The sync will generate native build files for your environment using gyp (Window
s: Visual Studio, OSX: XCode, Linux: make). This generation can also be forced m
anually: `gclient runhooks` |
| 60 |
| 61 To get just the source (not buildable): |
| 62 git clone https://chromium.googlesource.com/libyuv/libyuv |
| 63 |
| 64 |
| 65 ## Building the Library and Unittests |
| 66 |
| 67 ### Windows |
| 68 |
| 69 set GYP_DEFINES=target_arch=ia32 |
| 70 call python gyp_libyuv -fninja -G msvs_version=2013 |
| 71 ninja -j7 -C out\Release |
| 72 ninja -j7 -C out\Debug |
| 73 |
| 74 set GYP_DEFINES=target_arch=x64 |
| 75 call python gyp_libyuv -fninja -G msvs_version=2013 |
| 76 ninja -C out\Debug_x64 |
| 77 ninja -C out\Release_x64 |
| 78 |
| 79 #### Building with clangcl |
| 80 set GYP_DEFINES=clang=1 target_arch=ia32 libyuv_enable_svn=1 |
| 81 set LLVM_REPO_URL=svn://svn.chromium.org/llvm-project |
| 82 call python tools\clang\scripts\update.py |
| 83 call python gyp_libyuv -fninja libyuv_test.gyp |
| 84 ninja -C out\Debug |
| 85 ninja -C out\Release |
| 86 |
| 87 ### OSX |
| 88 |
| 89 Clang 64 bit shown. Remove `clang=1` for GCC and change x64 to ia32 for 32 bit. |
| 90 |
| 91 GYP_DEFINES="clang=1 target_arch=x64" ./gyp_libyuv |
| 92 ninja -j7 -C out/Debug |
| 93 ninja -j7 -C out/Release |
| 94 |
| 95 GYP_DEFINES="clang=1 target_arch=ia32" ./gyp_libyuv |
| 96 ninja -j7 -C out/Debug |
| 97 ninja -j7 -C out/Release |
| 98 |
| 99 ### iOS |
| 100 http://www.chromium.org/developers/how-tos/build-instructions-ios |
| 101 |
| 102 Add to .gclient last line: `target_os=['ios'];` |
| 103 |
| 104 armv7 |
| 105 |
| 106 GYP_DEFINES="OS=ios target_arch=armv7 target_subarch=arm32" GYP_CROSSCOMPILE
=1 GYP_GENERATOR_FLAGS="output_dir=out_ios" ./gyp_libyuv |
| 107 ninja -j7 -C out_ios/Debug-iphoneos libyuv_unittest |
| 108 ninja -j7 -C out_ios/Release-iphoneos libyuv_unittest |
| 109 |
| 110 arm64 |
| 111 |
| 112 GYP_DEFINES="OS=ios target_arch=arm64 target_subarch=arm64" GYP_CROSSCOMPILE
=1 GYP_GENERATOR_FLAGS="output_dir=out_ios" ./gyp_libyuv |
| 113 ninja -j7 -C out_ios/Debug-iphoneos libyuv_unittest |
| 114 ninja -j7 -C out_ios/Release-iphoneos libyuv_unittest |
| 115 |
| 116 both armv7 and arm64 (fat) |
| 117 |
| 118 GYP_DEFINES="OS=ios target_arch=armv7 target_subarch=both" GYP_CROSSCOMPILE=
1 GYP_GENERATOR_FLAGS="output_dir=out_ios" ./gyp_libyuv |
| 119 ninja -j7 -C out_ios/Debug-iphoneos libyuv_unittest |
| 120 ninja -j7 -C out_ios/Release-iphoneos libyuv_unittest |
| 121 |
| 122 simulator |
| 123 |
| 124 GYP_DEFINES="OS=ios target_arch=ia32 target_subarch=arm32" GYP_CROSSCOMPILE=
1 GYP_GENERATOR_FLAGS="output_dir=out_sim" ./gyp_libyuv |
| 125 ninja -j7 -C out_sim/Debug-iphonesimulator libyuv_unittest |
| 126 ninja -j7 -C out_sim/Release-iphonesimulator libyuv_unittest |
| 127 |
| 128 ### Android |
| 129 https://code.google.com/p/chromium/wiki/AndroidBuildInstructions |
| 130 |
| 131 Add to .gclient last line: `target_os=['android'];` |
| 132 |
| 133 armv7 |
| 134 |
| 135 GYP_DEFINES="OS=android" GYP_CROSSCOMPILE=1 ./gyp_libyuv |
| 136 ninja -j7 -C out/Debug libyuv_unittest_apk |
| 137 ninja -j7 -C out/Release libyuv_unittest_apk |
| 138 |
| 139 arm64 |
| 140 |
| 141 GYP_DEFINES="OS=android target_arch=arm64 target_subarch=arm64" GYP_CROSSCOM
PILE=1 ./gyp_libyuv |
| 142 ninja -j7 -C out/Debug libyuv_unittest_apk |
| 143 ninja -j7 -C out/Release libyuv_unittest_apk |
| 144 |
| 145 ia32 |
| 146 |
| 147 GYP_DEFINES="OS=android target_arch=ia32" GYP_CROSSCOMPILE=1 ./gyp_libyuv |
| 148 ninja -j7 -C out/Debug libyuv_unittest_apk |
| 149 ninja -j7 -C out/Release libyuv_unittest_apk |
| 150 |
| 151 GYP_DEFINES="OS=android target_arch=ia32 android_full_debug=1" GYP_CROSSCOMP
ILE=1 ./gyp_libyuv |
| 152 ninja -j7 -C out/Debug libyuv_unittest_apk |
| 153 |
| 154 mipsel |
| 155 |
| 156 GYP_DEFINES="OS=android target_arch=mipsel" GYP_CROSSCOMPILE=1 ./gyp_libyuv |
| 157 ninja -j7 -C out/Debug libyuv_unittest_apk |
| 158 ninja -j7 -C out/Release libyuv_unittest_apk |
| 159 |
| 160 arm64 disassembly: |
| 161 |
| 162 ./third_party/android_tools/ndk//toolchains/aarch64-linux-android-4.9/prebui
lt/linux-x86_64/bin/aarch64-linux-android-4android-objdump -d out/Release/obj/so
urce/libyuv.row_neon64.o |
| 163 |
| 164 Running tests: |
| 165 |
| 166 util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --rel
ease --gtest_filter=* |
| 167 |
| 168 Running test as benchmark: |
| 169 |
| 170 util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --rel
ease --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repea
t=999 --libyuv_flags=-1" |
| 171 |
| 172 Running test with C code: |
| 173 |
| 174 util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --rel
ease --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repea
t=999 --libyuv_flags=0 --libyuv_cpu_info=0" |
| 175 |
| 176 #### Building with GN |
| 177 |
| 178 call gn gen out/Release "--args=is_debug=false target_cpu=\"x86\"" |
| 179 call gn gen out/Debug "--args=is_debug=true target_cpu=\"x86\"" |
| 180 ninja -C out/Release |
| 181 ninja -C out/Debug |
| 182 |
| 183 ### Linux |
| 184 |
| 185 tools/clang/scripts/update.sh |
| 186 GYP_DEFINES="target_arch=x64" ./gyp_libyuv |
| 187 ninja -j7 -C out/Debug |
| 188 ninja -j7 -C out/Release |
| 189 |
| 190 GYP_DEFINES="target_arch=ia32" ./gyp_libyuv |
| 191 ninja -j7 -C out/Debug |
| 192 ninja -j7 -C out/Release |
| 193 |
| 194 #### CentOS |
| 195 |
| 196 On CentOS 32 bit the following work around allows a sync: |
| 197 |
| 198 export GYP_DEFINES="host_arch=ia32" |
| 199 gclient sync |
| 200 |
| 201 ### Windows Shared Library |
| 202 |
| 203 Modify libyuv.gyp from 'static_library' to 'shared_library', and add 'LIBYUV_BUI
LDING_SHARED_LIBRARY' to 'defines'. |
| 204 |
| 205 gclient runhooks |
| 206 |
| 207 After this command follow the building the library instructions above. |
| 208 |
| 209 If you get a compile error for atlthunk.lib on Windows, read http://www.chromium
.org/developers/how-tos/build-instructions-windows |
| 210 |
| 211 |
| 212 ### Build targets |
| 213 |
| 214 ninja -C out/Debug libyuv |
| 215 ninja -C out/Debug libyuv_unittest |
| 216 ninja -C out/Debug compare |
| 217 ninja -C out/Debug convert |
| 218 ninja -C out/Debug psnr |
| 219 ninja -C out/Debug cpuid |
| 220 |
| 221 |
| 222 ## Building the Library with make |
| 223 |
| 224 ### Linux |
| 225 |
| 226 make -j7 V=1 -f linux.mk |
| 227 make -j7 V=1 -f linux.mk clean |
| 228 make -j7 V=1 -f linux.mk CXX=clang++ |
| 229 |
| 230 ## Building the Library with cmake |
| 231 |
| 232 Install cmake: http://www.cmake.org/ |
| 233 |
| 234 Default debug build: |
| 235 |
| 236 mkdir out |
| 237 cd out |
| 238 cmake .. |
| 239 cmake --build . |
| 240 |
| 241 Release build/install |
| 242 |
| 243 mkdir out |
| 244 cd out |
| 245 cmake -DCMAKE_INSTALL_PREFIX="/usr/lib" -DCMAKE_BUILD_TYPE="Release" .. |
| 246 cmake --build . --config Release |
| 247 sudo cmake --build . --target install --config Release |
| 248 |
| 249 ### Windows 8 Phone |
| 250 |
| 251 Pre-requisite: |
| 252 |
| 253 * Install Visual Studio 2012 and Arm to your environment.<br> |
| 254 |
| 255 Then: |
| 256 |
| 257 call "c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_arm\vcv
arsx86_arm.bat" |
| 258 |
| 259 or with Visual Studio 2013: |
| 260 |
| 261 call "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_arm\vcv
arsx86_arm.bat" |
| 262 nmake /f winarm.mk clean |
| 263 nmake /f winarm.mk |
| 264 |
| 265 ### Windows Shared Library |
| 266 |
| 267 Modify libyuv.gyp from 'static_library' to 'shared_library', and add 'LIBYUV_BUI
LDING_SHARED_LIBRARY' to 'defines'. Then run this. |
| 268 |
| 269 gclient runhooks |
| 270 |
| 271 After this command follow the building the library instructions above. |
| 272 |
| 273 If you get a compile error for atlthunk.lib on Windows, read http://www.chromium
.org/developers/how-tos/build-instructions-windows |
| 274 |
| 275 ### 64 bit Windows |
| 276 |
| 277 set GYP_DEFINES=target_arch=x64 |
| 278 gclient runhooks V=1 |
| 279 |
| 280 ### ARM Linux |
| 281 |
| 282 export GYP_DEFINES="target_arch=arm" |
| 283 export CROSSTOOL=`<path>`/arm-none-linux-gnueabi |
| 284 export CXX=$CROSSTOOL-g++ |
| 285 export CC=$CROSSTOOL-gcc |
| 286 export AR=$CROSSTOOL-ar |
| 287 export AS=$CROSSTOOL-as |
| 288 export RANLIB=$CROSSTOOL-ranlib |
| 289 gclient runhooks |
| 290 |
| 291 ## Running Unittests |
| 292 |
| 293 ### Windows |
| 294 |
| 295 out\Release\libyuv_unittest.exe --gtest_catch_exceptions=0 --gtest_filter="*
" |
| 296 |
| 297 ### OSX |
| 298 |
| 299 out/Release/libyuv_unittest --gtest_filter="*" |
| 300 |
| 301 ### Linux |
| 302 |
| 303 out/Release/libyuv_unittest --gtest_filter="*" |
| 304 |
| 305 Replace --gtest_filter="*" with specific unittest to run. May include wildcards
. e.g. |
| 306 |
| 307 out/Release/libyuv_unittest --gtest_filter=libyuvTest.I420ToARGB_Opt |
| 308 |
| 309 ## CPU Emulator tools |
| 310 |
| 311 ### Intel SDE (Software Development Emulator) |
| 312 |
| 313 Pre-requisite: Install IntelSDE for Windows: http://software.intel.com/en-us/art
icles/intel-software-development-emulator |
| 314 |
| 315 Then run: |
| 316 |
| 317 c:\intelsde\sde -hsw -- out\release\libyuv_unittest.exe --gtest_filter=* |
| 318 |
| 319 |
| 320 ## Memory tools |
| 321 |
| 322 ### Running Dr Memory memcheck for Windows |
| 323 |
| 324 Pre-requisite: Install Dr Memory for Windows and add it to your path: http://www
.drmemory.org/docs/page_install_windows.html |
| 325 |
| 326 set GYP_DEFINES=build_for_tool=drmemory target_arch=ia32 |
| 327 call python gyp_libyuv -fninja -G msvs_version=2013 |
| 328 ninja -C out\Debug |
| 329 drmemory out\Debug\libyuv_unittest.exe --gtest_catch_exceptions=0 --gtest_fi
lter=* |
| 330 |
| 331 ### Running UBSan |
| 332 |
| 333 See Chromium instructions for sanitizers: https://www.chromium.org/developers/te
sting/undefinedbehaviorsanitizer |
| 334 |
| 335 Sanitizers available: TSan, MSan, ASan, UBSan, LSan |
| 336 |
| 337 GYP_DEFINES='ubsan=1' gclient runhooks |
| 338 ninja -C out/Release |
| 339 |
| 340 ### Running Valgrind memcheck |
| 341 |
| 342 Memory errors and race conditions can be found by running tests under special me
mory tools. [Valgrind] [1] is an instrumentation framework for building dynamic
analysis tools. Various tests and profilers are built upon it to find memory han
dling errors and memory leaks, for instance. |
| 343 |
| 344 [1]: http://valgrind.org |
| 345 |
| 346 solutions = [ |
| 347 { "name" : "libyuv", |
| 348 "url" : "https://chromium.googlesource.com/libyuv/libyuv", |
| 349 "deps_file" : "DEPS", |
| 350 "managed" : True, |
| 351 "custom_deps" : { |
| 352 "libyuv/chromium/src/third_party/valgrind": "https://chromium.googles
ource.com/chromium/deps/valgrind/binaries", |
| 353 }, |
| 354 "safesync_url": "", |
| 355 }, |
| 356 ] |
| 357 |
| 358 Then run: |
| 359 |
| 360 GYP_DEFINES="clang=0 target_arch=x64 build_for_tool=memcheck" python gyp_lib
yuv |
| 361 ninja -C out/Debug |
| 362 valgrind out/Debug/libyuv_unittest |
| 363 |
| 364 |
| 365 For more information, see http://www.chromium.org/developers/how-tos/using-valgr
ind |
| 366 |
| 367 ### Running Thread Sanitizer (TSan) |
| 368 |
| 369 GYP_DEFINES="clang=0 target_arch=x64 build_for_tool=tsan" python gyp_libyuv |
| 370 ninja -C out/Debug |
| 371 valgrind out/Debug/libyuv_unittest |
| 372 |
| 373 For more info, see http://www.chromium.org/developers/how-tos/using-valgrind/thr
eadsanitizer |
| 374 |
| 375 ### Running Address Sanitizer (ASan) |
| 376 |
| 377 GYP_DEFINES="clang=0 target_arch=x64 build_for_tool=asan" python gyp_libyuv |
| 378 ninja -C out/Debug |
| 379 valgrind out/Debug/libyuv_unittest |
| 380 |
| 381 For more info, see http://dev.chromium.org/developers/testing/addresssanitizer |
| 382 |
| 383 ## Benchmarking |
| 384 |
| 385 The unittests can be used to benchmark. |
| 386 |
| 387 ### Windows |
| 388 |
| 389 set LIBYUV_WIDTH=1280 |
| 390 set LIBYUV_HEIGHT=720 |
| 391 set LIBYUV_REPEAT=999 |
| 392 set LIBYUV_FLAGS=-1 |
| 393 out\Release\libyuv_unittest.exe --gtest_filter=*I420ToARGB_Opt |
| 394 |
| 395 |
| 396 ### Linux and Mac |
| 397 |
| 398 LIBYUV_WIDTH=1280 LIBYUV_HEIGHT=720 LIBYUV_REPEAT=1000 out/Release/libyuv_un
ittest --gtest_filter=*I420ToARGB_Opt |
| 399 |
| 400 libyuvTest.I420ToARGB_Opt (547 ms) |
| 401 |
| 402 Indicates 0.547 ms/frame for 1280 x 720. |
| 403 |
| 404 ## Making a change |
| 405 |
| 406 gclient sync |
| 407 git checkout -b mycl -t origin/master |
| 408 git pull |
| 409 <edit files> |
| 410 git add -u |
| 411 git commit -m "my change" |
| 412 git cl lint |
| 413 git cl try |
| 414 git cl upload -r a-reviewer@chomium.org -s |
| 415 <once approved..> |
| 416 git cl land |
OLD | NEW |