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