Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: README.chromium

Issue 9290059: Initial commit of all previous Chrome build scripts. (Closed) Base URL: http://git.chromium.org/chromium/third_party/ffmpeg.git@master
Patch Set: Drop deprecated subfolder. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 Name: ffmpeg
2 URL: http://ffmpeg.org/
3 License File: patched-ffmpeg/LICENSE
4
5 This file describes how to produce the FFmpeg include directory, and how to
6 create the ffmpeg.gyp file and related configurations.
7
8 -- FFmpeg headers in the 'include' directory.
9
10 The include directory contains FFmpeg's public header files from the output of
11 a "make install" command. The header files are from Chromium's copy of FFmpeg.
12
13 Steps to reproduce:
14 1) If on Windows, refer to our MinGW/MSYS environment setup:
15 http://src.chromium.org/viewvc/chrome/trunk/deps/third_party/mingw/
16 2) Grab Chromium's copy of FFmpeg:
17 http://src.chromium.org/viewvc/chrome/trunk/deps/third_party/ffmpeg/
18 3) Follow the instructions to build and install.
19 4) Go to your install location and copy the following into the Chromium tree:
20 /path/to/install/include/libavcodec
21 /path/to/install/include/libavformat
22 /path/to/install/include/libavutil
23
24 The project contains some hand-written DEF files used to generate import
25 libraries to permit dynamically loading FFmpeg. On Windows, the libraries are
26 linked in using /DELAYLOAD to avoid having the DLLs present at run-time. On
27 POSIX systems, dlopen() is used to achieve a similar effect.
28
29 We don't use the import libraries generated from building FFmpeg because they
30 export every method by ordinal, which makes binary compatibility with different
31 builds of FFmpeg difficult if not impossible. Furthermore, it is much easier
32 to update a DEF file instead of rebuilding FFmpeg to generate new import
33 libraries.
34
35
36 -- Recreating the ffmpeg.gyp file and populating the config directory.
37 The ffmpeg.gyp file is meant to be used in place of FFmpeg's
38
39 ./configure && make
40
41 steps. The file was created by inspecting the build log from above.
42 The FFmpeg build is relatively straightforward. All files are built with
43 the same CFLAGS. The config.h and version.h files are the only files generated
44 by ./configure that are included elsewhere. They require a small bit of
45 post-processing.
46
47 Other than the configure step, FFmpeg just compiles its .c files, assembles a
48 few more using yasm, and that's it. Exact instructions for reproducing
49 ffmpeg.gyp are in the "Detailed Directions" section.
50
51 Here is a list of gotchas that have shown up.
52 1) FFmpeg requires special configure (--disable-optimizations) in order
53 to be built with -O0 successfully due to some of the hand-written
54 assembler using ebp. -O0 implies -fno-omit-frame-pointer which breaks
55 this. This will produce compiler errors like:
56 libavcodec/cabac.h:527: error: can't find a register in class
57 'GENERAL_REGS' while reloading 'asm'
58 cabac.h:527: error: 'asm' operand has impossible constraints
59
60 2) On ia32, FFmpeg cannot be built with -fPIC, again due to assembly
61 issues. There may be a workaround, but the performance impact is
62 unknown.
63
64 3) Sometimes, with -O0, invalid code will be exposed because dead-branch
65 pruning is disabled in gcc. This can manifest itself as strange link
66 issues or compile issues. Be careful to read all warnings in this case.
67
68 4) Since config.h is generated via ./configure, the generated file will
69 be sensitive to the configuration of the machine it was produced on.
70 In particular, yasm does not seem to always be detected if
71 cross-compiling for 32-bit on a 64-bit machine. Since yasm is built in
72 tree, make sure to force things with --enable-yasm.
73
74 5) yasm needs to be installed on mac and windows if not already there.
75
76 6) Similar to issue #4, ./configure may detect the presence of SDL and
77 adjust config.h accordingly. This is harmless because all the SDL
78 related code has been disabled in our configuration.
79
80 7) On ia32, we want to be able to compile with WITHOUT -fomit-frame-pointer
81 (so breakpad can function). To do this, we need to disable the use of the
82 EBP register, otherwise some of FFmpeg's inline assembly will cause
83 compilation errors similar to gotcha #1. For more details, see the file
84 comment in the munge_config_optimizations.sh. This script will fix up
85 the generated config.h to be building without -fomit-frame-pointer.
86
87 Short Directions:
88 =================
89 1) Create patched source tree
90
91 ./make_src_tree.sh ffmpeg.tar.gz source/patched-ffmpeg patches
92
93 2) Create config.h and config.asm as needed.
94 On Linux run
95 ./build_ffmpeg.sh linux ia32 <absolute path to ..>
96 ./build_ffmpeg.sh linux x64 <absolute path to ..>
97
98 On Linux chroot run
99 ./build_ffmpeg.sh linux arm <absolute path to ..>
100 ./build_ffmpeg.sh linux arm-neon <absolute path to ..>
101
102 On Mac run
103 ./build_ffmpeg.sh mac ia32 <absolute path to ..>
104
105 On Windows run
106 ./build_ffmpeg.sh win ia32 <absolute path to ..>
107
108 3) Finally, collect all these directories and copy all config files
109 into the source tree using
110
111 ./copy_config.sh
112
113 Detailed Directions:
114 ====================
115 1) Get a clean version of the patched tree. This should be here:
116
117 src/third_party/ffmpeg/source/patched-ffmpeg
118
119 2) Run the configure in a directory out of the tree with the arguments you
120 want. To see what was used before, find the config.h for the platform
121 of interest in:
122
123 src/third_party/ffmpeg/source/config/[branding]/[platform]/[variant]
124
125 The value of the FFMPEG_CONFIGURATION macro should have the configure
126 commandline that generated the file.
127
128 Note that if you are trying to build a 32-bit FFmpeg for linux on a
129 64-bit box, the extra flags you want to pass to ./configure are
130
131 --arch=i686 --extra-cflags=-m32 --extra-ldflags=-m32
132
133 Also, as noted in gotcha #4, explicitly setting --enable-yasm is
134 a good idea. (These flags have been added to build_ffmpeg.sh.)
135
136 3) Copy the newly generated config.h and version.h into the correct platform
137 location:
138
139 src/third_party/ffmpeg/source/config/[branding]/[platform]/[variant]
140
141 Make sure to double-check that config.h and version.h are the only files
142 of interest. By that, I mean check that the other generated files are
143 makefiles, documentation, .pc files, or something else that is not
144 relevant to our build.
145
146 TODO(ajwong): Check if we can modify version.h to tag our builds.
147
148 3b) If on ia32, handle gotcha #6 by munging the geneated config.h file to
149 disable use of EBP. Call the munge_config_optimizations.sh script on
150 the config.h for each ia32 variant. (This has been implemented in
151 build_ffmpeg.sh.)
152
153 ** This script is not idempotent. Don't run it twice **
154
155 Remember, this is only necessary for ia32 config.h files. Running this
156 on config.h files for other platforms (in particular, for x64) will
157 likely result in unecessarily slow code, or compile failures.
158
159 4) Next, capture all the output from a build of libavcodec.so and
160 libavformat.so. We will use the build log as a reference for making
161 the ffmpeg.gyp file.
162
163 make libavcodec/libavcodec.so libavformat/libavformat.so \
164 > ffmpeg_build_log 2> ffmpeg_build_err
165
166 For Mac, replace the ".so" in the files above with ".dylib".
167
168 To get detailed output you might have to comment in common.mak
169
170 #$(foreach VAR,$(BRIEF), \
171 # $(eval override $(VAR) = $($(VAR))))
172
173 5) Check ffmpeg_build_err to see if there are any significant
174 anomalies. FFmpeg source generates a lot of compiler warnings; it
175 is safe to ignore those.
176
177 6) Examine all non-gcc commands to see if we're missing anything
178 interesting:
179
180 grep -v '^gcc' ffmpeg_build_log
181
182 There should be yasm commands for assembling two yasm files, but nothing
183 else. Include those yasm files in the sources list for gyp. That means
184
185 grep -v '^gcc\|^yasm'
186
187 should generate nothing beyond "cd" and "ln" commands.
188
189 7) Verify that the all the gcc commands have the same compiler flags.
190 Do that with the following "one-liner":
191
192 grep - '^gcc' ffmpeg_build_log |
193 grep -v ' -MM ' |
194 grep -v ' -shared ' |
195 sed -e 's/ -MF .*$//' |
196 sort | uniq -c
197
198 This should find all gcc commands, exclude the dependency generation
199 lines, the link lines, and strip the output/input file names leaving
200 just the compiler flags + invocation. You should only see one "line"
201 of output. If there is more than one, figure out if the differences
202 in compiler flags are significant, and then use your best judgment.
203
204 Look at gotcha #2 in for notes about the -fPIC flag in particular.
205
206 8) Examine the output from step 7 and update the compiler flags in
207 ffmpeg.gyp. For easier cut/paste, append the following to the previous
208 command line to isolate each flag on its own line and add
209 single-quotes:
210
211 tr -s ' ' | tr ' ' '\n' | sed -e "s/\(.*\)/'\1',/" | sort -u
212
213 9) Next, examine the link flags to see if anything interesting appears.
214
215 grep ' -shared ' ffmpeg_build_log |
216 tr ' ' '\n' |
217 grep -Ev '^[^-].*' |
218 grep -v rpath |
219 grep -Ev '^-L' |
220 sort -u
221
222 This should find all link lines, move each flag to its own line,
223 remove any argument that isn't a flag, remove all the rpaths (not
224 useful for us anyways), and remove all the -L lines (also not useful
225 for us).
226
227 The most interesting will likely be the -Wl,.* lines. Update the
228 ldflags section in ffmpeg.gyp accordingly.
229
230 10) Lastly, Find all the build .c files and update the sources line (this is
231 very similar to step 7):
232
233 grep -E '^gcc' ffmpeg_build_log |
234 grep -v ' -MM ' |
235 grep -v ' -shared ' |
236 sed -e "s|.* -o .* \(.*\)$|'source/patched-ffmpeg/\1',|" |
237 sort
238
239 11) Attempt to build. :)
240
241 *12) Update the the sources! clause to exclude files that should only be built
242 for Chromium. For this, you basically need to do the steps above once
243 with the configure options for Chrome, then once with the options for
244 Chromium and diff the list of .c and .asm source files.
OLDNEW
« no previous file with comments | « OWNERS ('k') | chromium/avcodec-53.sigs » ('j') | codereview.settings » ('J')

Powered by Google App Engine
This is Rietveld 408576698