Skip to content

Commit 60c4d82

Browse files
Chris Watkinswolenetz
Chris Watkins
authored andcommitted
Delete gyp files
Gyp is no longer supported. This deletes the gyp files and updates all references to them. generate_gyp.py is renamed to generate_gn.py. BUG=641113 TEST=generate_gn_unittest.py fails 11/19 with and without this change Change-Id: I51d9bd064ac1c480153da229638174e6e80a95a1 Reviewed-on: https://chromium-review.googlesource.com/376120 Reviewed-by: Matthew Wolenetz <[email protected]>
1 parent 75976ae commit 60c4d82

File tree

8 files changed

+49
-1321
lines changed

8 files changed

+49
-1321
lines changed

BUILD.gn

+3-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if (has_yasm_deps) {
4646

4747
if (is_mac) {
4848
# Necessary to ensure symbols end up with a _ prefix; added by
49-
# yasm_compile.gypi for Windows, but not Mac.
49+
# yasm_assemble.gni for Windows, but not Mac.
5050
defines += [ "PREFIX" ]
5151
}
5252
}
@@ -145,7 +145,8 @@ target(link_target_type, "ffmpeg_internal") {
145145
"_XOPEN_SOURCE=600",
146146
"PIC",
147147
# Disable deprecated features that generate spammy warnings.
148-
# ffmpeg.gyp & media/ffmpeg/ffmpeg_common.h must be kept in sync.
148+
# media/ffmpeg/ffmpeg_common.h defines these as well and must be kept
149+
# in sync with this file.
149150
"FF_API_CONVERGENCE_DURATION=0",
150151
# Upstream libavcodec/utils.c still uses the deprecated
151152
# av_dup_packet(), causing deprecation warnings.

README.chromium

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ License File: CREDITS.chromium
55
Upstream Git: git://source.ffmpeg.org/ffmpeg.git
66
Last Upstream Merge: 855d9d29ebf135b08ffdc7436e529a3ab767f977, Feb 11 2016
77

8-
This file documents the layout of the Chromium copy of FFmpeg git, some common
9-
tasks, how to produce the FFmpeg include directory, and how to create the
10-
ffmpeg.gyp file and related configurations.
8+
This file documents the layout of the Chromium copy of FFmpeg, some common
9+
tasks, and how to create the build files and related configurations.
1110

12-
FFmpeg Git Layout:
13-
==================
11+
FFmpeg Layout:
12+
==============
1413

15-
Chromium's copy of FFmpeg is a fork of the upstream git repository, see the tags
16-
above for up-to-date cut information. All of the Chromium-specific bits, minus
17-
the gyp files, are located under the chromium/ folder off the root.
14+
Chromium's copy of FFmpeg is a fork of the upstream git repository, see the
15+
tags above for the latest merged upstream revision. All of the
16+
Chromium-specific bits, minus the gn files, are located under the chromium/
17+
folder off the root.
1818

19-
ffmpeg.gyp: See the section on ffmpeg.gyp below.
19+
BUILD.gn: Has the targets for building FFmpeg for Chrome.
2020

21-
ffmpeg_generated.gypi: Pregenerated gyp listing of files necessary to build
22-
every platform. See chromium/scripts/generate_gyp.py for more details.
21+
ffmpeg_generated.gni: Pregenerated listing of files necessary to build
22+
every platform. See chromium/scripts/generate_gn.py for more details.
2323

24-
chromium/scripts: Utilities for building the gyp and config files.
24+
chromium/scripts: Utilities for building the gn and config files.
2525

2626
chromium/config/...: Pregenerated FFmpeg config options for each platform
2727
and architecture; e.g., ChromeOS: ARM-Neon, Linux: X64, etc.

chromium/patches/README

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Upstream cherry-picks:
1414
Autorename:
1515
autorename_* files are renamed copies of various files that would cause
1616
base name collisions from mac libtool. These files are generated
17-
by generate_gyp.py. https://chromium-review.googlesource.com/#/c/274543/
17+
by generate_gn.py. https://chromium-review.googlesource.com/#/c/274543/
1818

1919
Current patches:
2020
.gitignore has a "Chromium stuff" section.

chromium/scripts/build_ffmpeg.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def BuildFFmpeg(target_os, target_arch, host_os, host_arch, parallel_jobs,
236236
RewriteFile(
237237
os.path.join(config_dir, 'config.h'),
238238
r'(#define HAVE_VFP_ARGS [01])',
239-
r'/* \1 -- Disabled to allow softfp/hardfp selection at gyp time */')
239+
(r'/* \1 -- softfp/hardfp selection is done by the chrome build */'))
240240

241241

242242
def main(argv):
@@ -246,7 +246,7 @@ def main(argv):
246246
help='Branding to build; determines e.g. supported codecs')
247247
parser.add_option('--config-only', action='store_true',
248248
help='Skip the build step. Useful when a given platform '
249-
'is not necessary for generate_gyp.py')
249+
'is not necessary for generate_gn.py')
250250
options, args = parser.parse_args(argv)
251251

252252
if len(args) < 2:
@@ -401,7 +401,8 @@ def main(argv):
401401
# av_get_cpu_flags() is run outside of the sandbox when enabled.
402402
'--enable-neon',
403403
'--extra-cflags=-mtune=generic-armv7-a',
404-
# NOTE: softfp/hardfp selected at gyp time.
404+
# Enabling softfp lets us choose either softfp or hardfp when doing
405+
# the chrome build.
405406
'--extra-cflags=-mfloat-abi=softfp',
406407
])
407408
if target_arch == 'arm-neon':
@@ -420,7 +421,7 @@ def main(argv):
420421
'--target-os=linux',
421422
'--cross-prefix=armv7a-cros-linux-gnueabi-',
422423
'--extra-cflags=-mtune=cortex-a8',
423-
# NOTE: softfp/hardfp selected at gyp time.
424+
# NOTE: we don't need softfp for this hardware.
424425
'--extra-cflags=-mfloat-abi=hard',
425426
])
426427

chromium/scripts/generate_gyp.py chromium/scripts/generate_gn.py

+17-138
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,21 @@
44
# Use of this source code is governed by a BSD-style license that can be
55
# found in the LICENSE file.
66

7-
"""Creates a GYP include file for building FFmpeg from source.
7+
"""Creates a GN include file for building FFmpeg from source.
88
99
The way this works is a bit silly but it's easier than reverse engineering
10-
FFmpeg's configure scripts and Makefiles. It scans through build directories for
11-
object files then does a reverse lookup against the FFmpeg source tree to find
12-
the corresponding C or assembly file.
10+
FFmpeg's configure scripts and Makefiles and manually maintaining chromium
11+
build files. It scans through build directories for object files then does a
12+
reverse lookup against the FFmpeg source tree to find the corresponding C or
13+
assembly file.
1314
14-
Running build_ffmpeg.sh on each supported platform for all architecture is
15+
Running build_ffmpeg.py on each supported platform for all architectures is
1516
required prior to running this script. See build_ffmpeg.py for details as well
1617
as the documentation at:
1718
18-
https://docs.google.com/document/d/14bqZ9NISsyEO3948wehhJ7wc9deTIz-yHUhF1MQp7Po/edit?pli=1#heading=h.x346hhrqw4lx
19+
https://docs.google.com/document/d/14bqZ9NISsyEO3948wehhJ7wc9deTIz-yHUhF1MQp7Po/edit
1920
2021
Once you've built all platforms and architectures you may run this script.
21-
22-
While this seems insane, reverse engineering and maintaining a gyp file by hand
23-
is significantly more painful.
2422
"""
2523

2624
__author__ = '[email protected] (Andrew Scherkus)'
@@ -44,40 +42,10 @@
4442
# Use of this source code is governed by a BSD-style license that can be
4543
# found in the LICENSE file.
4644
47-
# NOTE: this file is autogenerated by ffmpeg/chromium/scripts/generate_gyp.py
45+
# NOTE: this file is autogenerated by ffmpeg/chromium/scripts/generate_gn.py
4846
4947
""" % (datetime.datetime.now().year)
5048

51-
GYP_HEADER = """
52-
{
53-
'variables': {
54-
"""
55-
56-
GYP_FOOTER = """ },
57-
}
58-
"""
59-
60-
61-
GYP_CONDITIONAL_BEGIN = """ 'conditions': [
62-
"""
63-
GYP_CONDITIONAL_END = """ ], # conditions
64-
"""
65-
GYP_CONDITIONAL_STANZA_BEGIN = """ ['%s', {
66-
"""
67-
GYP_CONDITIONAL_STANZA_ITEM = """ '%s',
68-
"""
69-
GYP_CONDITIONAL_STANZA_OUTPUT_ITEM = """ '<(shared_generated_dir)/%s',
70-
"""
71-
GYP_CONDITIONAL_STANZA_END = """ }], # %s
72-
"""
73-
74-
GYP_CONDITIONAL_C_SOURCE_STANZA_BEGIN = """ 'c_sources': [
75-
"""
76-
GYP_CONDITIONAL_ASM_SOURCE_STANZA_BEGIN = """ 'asm_sources': [
77-
"""
78-
GYP_CONDITIONAL_ITEM_STANZA_END = """ ],
79-
"""
80-
8149
GN_HEADER = """import("//build/config/arm.gni")
8250
import("ffmpeg_options.gni")
8351
@@ -103,7 +71,7 @@
10371
GN_SOURCE_END = """]
10472
"""
10573

106-
# Controls GYP conditional stanza generation.
74+
# Controls conditional stanza generation.
10775
Attr = enum('ARCHITECTURE', 'TARGET', 'PLATFORM')
10876
SUPPORT_MATRIX = {
10977
Attr.ARCHITECTURE:
@@ -114,7 +82,7 @@
11482

11583

11684
def NormalizeFilename(name):
117-
""" Removes leading path separators in an attempt to normalize paths."""
85+
"""Removes leading path separators in an attempt to normalize paths."""
11886
return string.lstrip(name, os.sep)
11987

12088

@@ -200,7 +168,7 @@ def GetSourceFiles(source_dir):
200168
"""
201169

202170
def IsSourceDir(d):
203-
return d not in ['.git', '.svn']
171+
return d != '.git'
204172

205173
source_files = []
206174
for root, dirs, files in os.walk(source_dir):
@@ -345,80 +313,8 @@ def IsEmpty(self):
345313
"""
346314
return (len(self.sources) == 0 or len(self.conditions) == 0)
347315

348-
def GenerateGypStanza(self):
349-
"""Generates a gyp conditional stanza representing this source set.
350-
351-
TODO(scherkus): Having all this special case condition optimizing logic in
352-
here feels a bit dirty, but hey it works. Perhaps refactor if it starts
353-
getting out of hand.
354-
355-
Returns:
356-
A string of gyp code.
357-
"""
358-
359-
conjunctions = []
360-
for condition in self.conditions:
361-
if condition.ARCHITECTURE == '*':
362-
arch_condition = None
363-
elif condition.ARCHITECTURE == 'arm-neon':
364-
arch_condition = 'target_arch == "arm" and arm_neon == 1'
365-
else:
366-
arch_condition = 'target_arch == "%s"' % condition.ARCHITECTURE
367-
368-
if condition.TARGET == '*':
369-
target_condition = None
370-
else:
371-
target_condition = 'ffmpeg_branding == "%s"' % condition.TARGET
372-
373-
if condition.PLATFORM == '*':
374-
platform_condition = None
375-
else:
376-
platform_condition = 'OS == "%s"' % condition.PLATFORM
377-
378-
conjunction_parts = filter(
379-
None, [platform_condition, arch_condition, target_condition])
380-
conjunctions.append(' and '.join(conjunction_parts))
381-
382-
# If there is more that one clause, wrap various conditions in parens
383-
# before joining.
384-
if len(conjunctions) > 1:
385-
conjunctions = ['(%s)' % x for x in conjunctions]
386-
387-
# Sort conjunctions to make order deterministic.
388-
joined_conjunctions = ' or '.join(sorted(conjunctions))
389-
if not joined_conjunctions:
390-
joined_conjunctions = '(1)'
391-
392-
stanza = []
393-
stanza += GYP_CONDITIONAL_STANZA_BEGIN % (joined_conjunctions)
394-
395-
self.sources = sorted(n.replace('\\', '/') for n in self.sources)
396-
397-
# Write out all C sources.
398-
c_sources = filter(IsCFile, self.sources)
399-
if c_sources:
400-
stanza += GYP_CONDITIONAL_C_SOURCE_STANZA_BEGIN
401-
for name in c_sources:
402-
stanza += GYP_CONDITIONAL_STANZA_ITEM % (name)
403-
stanza += GYP_CONDITIONAL_ITEM_STANZA_END
404-
405-
# Write out all assembly sources.
406-
asm_sources = filter(IsAssemblyFile, self.sources)
407-
if asm_sources:
408-
stanza += GYP_CONDITIONAL_ASM_SOURCE_STANZA_BEGIN
409-
for name in asm_sources:
410-
stanza += GYP_CONDITIONAL_STANZA_ITEM % (name)
411-
stanza += GYP_CONDITIONAL_ITEM_STANZA_END
412-
413-
stanza += GYP_CONDITIONAL_STANZA_END % (joined_conjunctions)
414-
return ''.join(stanza)
415-
416316
def GenerateGnStanza(self):
417-
"""Generates a gyp conditional stanza representing this source set.
418-
419-
TODO(scherkus): Having all this special case condition optimizing logic in
420-
here feels a bit dirty, but hey it works. Perhaps refactor if it starts
421-
getting out of hand.
317+
"""Generates a gn conditional stanza representing this source set.
422318
"""
423319

424320
conjunctions = []
@@ -708,19 +604,6 @@ def ParseOptions():
708604
return options, args
709605

710606

711-
def WriteGyp(fd, disjoint_sets):
712-
fd.write(COPYRIGHT)
713-
fd.write(GYP_HEADER)
714-
715-
# Generate conditional stanza for each disjoint source set.
716-
fd.write(GYP_CONDITIONAL_BEGIN)
717-
for s in disjoint_sets:
718-
fd.write(s.GenerateGypStanza())
719-
fd.write(GYP_CONDITIONAL_END)
720-
721-
fd.write(GYP_FOOTER)
722-
723-
724607
def WriteGn(fd, disjoint_sets):
725608
fd.write(COPYRIGHT)
726609
fd.write(GN_HEADER)
@@ -730,7 +613,7 @@ def WriteGn(fd, disjoint_sets):
730613
fd.write(s.GenerateGnStanza())
731614

732615

733-
# Lists of files that are exempt from searching in GetIncludeSources.
616+
# Lists of files that are exempt from searching in GetIncludedSources.
734617
IGNORED_INCLUDE_FILES = [
735618
# Chromium generated files
736619
'config.h',
@@ -1035,15 +918,11 @@ def main():
1035918
print 'License checks passed.'
1036919
UpdateCredits(sources_to_check, source_dir)
1037920

1038-
def WriteOutputFile(outfile, func):
1039-
output_name = os.path.join(options.source_dir, outfile)
1040-
print 'Output:', output_name
1041-
1042-
with open(output_name, 'w') as fd:
1043-
func(fd, sets)
921+
gn_file_name = os.path.join(options.source_dir, 'ffmpeg_generated.gni')
922+
print 'Writing:', gn_file_name
923+
with open(gn_file_name, 'w') as fd:
924+
WriteGn(fd, sets)
1044925

1045-
WriteOutputFile('ffmpeg_generated.gni', WriteGn)
1046-
WriteOutputFile('ffmpeg_generated.gypi', WriteGyp)
1047926

1048927
if __name__ == '__main__':
1049928
main()

0 commit comments

Comments
 (0)