Skip to content

Commit

Permalink
build: Parametrize output language (#5158)
Browse files Browse the repository at this point in the history
Modify build script to support customizing output language. Custom
builds now can be prepared with `ECMASCRIPT_2015` or higher to reduce
bundle size on newer platforms.
  • Loading branch information
tykus160 authored Apr 19, 2023
1 parent 3b0f013 commit 382f316
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
shaka_version = shakaBuildHelpers.calculate_version()

common_closure_opts = [
'--language_out', 'ECMASCRIPT5',

'--jscomp_error=*',

# Turn off complaints like:
Expand Down Expand Up @@ -265,11 +263,12 @@ def parse_build(self, lines, root):

return True

def build_library(self, name, locales, force, is_debug):
def build_library(self, name, langout, locales, force, is_debug):
"""Builds Shaka Player using the files in |self.include|.
Args:
name: The name of the build.
langout: Closure Compiler output language.
locales: A list of strings of locale identifiers.
force: True to rebuild, False to ignore if no changes are detected.
is_debug: True to compile for debugging, false for release.
Expand All @@ -294,6 +293,7 @@ def build_library(self, name, locales, force, is_debug):
closure = compiler.ClosureCompiler(self.include, build_name)

closure_opts = common_closure_opts + common_closure_defines
closure_opts += ['--language_out', langout]
if is_debug:
closure_opts += debug_closure_opts + debug_closure_defines
else:
Expand Down Expand Up @@ -363,6 +363,12 @@ def main(args):
type=str,
default='ui')

parser.add_argument(
'--langout',
help='Set closure compiler output language. Defaults to ECMASCRIPT5.',
type=str,
default='ECMASCRIPT5')

parsed_args, commands = parser.parse_known_args(args)

# Make the dist/ folder, ignore errors.
Expand All @@ -389,11 +395,12 @@ def main(args):
return 1

name = parsed_args.name
langout = parsed_args.langout
locales = parsed_args.locales
force = parsed_args.force
is_debug = parsed_args.mode == 'debug'

if not custom_build.build_library(name, locales, force, is_debug):
if not custom_build.build_library(name, langout, locales, force, is_debug):
return 1

return 0
Expand Down

0 comments on commit 382f316

Please sign in to comment.