<commit_before># Copyright 2014 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

dir=$(dirname "$BASH_SOURCE")/..

function calculate_version() {
  cd "$dir"
  # Check git tags for a version number, noting if the sources are dirty.
  if ! git describe --tags --dirty 2>/dev/null; then
    # Fall back to NPM's installed package version, and assume the sources
    # are dirty since the build scripts are being run at all after install.
    npm ls | grep shaka-player | sed -e 's/.*@\(.*\?\) .*/\1-npm-dirty/'
  fi
}

GIT_VERSION=$(calculate_version)

# 'deprecatedAnnotations' controls complaints about @expose, but the new
# @nocollapse annotation does not do the same job for properties.
# So since we can't use the new annotations, we have to ignore complaints
# about the old one.

closure_opts="
  --language_in ECMASCRIPT5
  --language_out ECMASCRIPT5

  --jscomp_error=accessControls
  --jscomp_error=ambiguousFunctionDecl
  --jscomp_error=checkDebuggerStatement
  --jscomp_error=checkRegExp
  --jscomp_error=checkTypes
  --jscomp_error=checkVars
  --jscomp_error=const
  --jscomp_error=constantProperty
  --jscomp_error=deprecated
  --jscomp_error=duplicate
  --jscomp_error=es5Strict
  --jscomp_error=externsValidation
  --jscomp_error=fileoverviewTags
  --jscomp_error=globalThis
  --jscomp_error=internetExplorerChecks
  --jscomp_error=invalidCasts
  --jscomp_error=missingProperties
  --jscomp_error=nonStandardJsDocs
  --jscomp_error=strictModuleDepCheck
  --jscomp_error=suspiciousCode
  --jscomp_error=undefinedNames
  --jscomp_error=undefinedVars
  --jscomp_error=unknownDefines
  --jscomp_error=uselessCode
  --jscomp_error=visibility

  --jscomp_off=deprecatedAnnotations

  --extra_annotation_name=listens
  --extra_annotation_name=exportDoc

  -O ADVANCED
  --generate_exports
  --output_wrapper_file="$dir"/build/wrapper.template.js

  -D COMPILED=true
  -D goog.DEBUG=false
  -D goog.STRICT_MODE_COMPATIBLE=true
  -D goog.ENABLE_DEBUG_LOADER=false
  -D shaka.asserts.ENABLE_ASSERTS=false
  -D shaka.log.MAX_LOG_LEVEL=0
  -D GIT_VERSION='$GIT_VERSION'
"

set -e

function library_sources_0() {
  find \
    "$dir"/lib \
    "$dir"/externs \
    -name '*.js' -print0
}

function test_sources_0() {
  find \
    "$dir"/spec \
    -name '*.js' -print0
}

function closure_sources_0() {
  find \
    "$dir"/third_party/closure \
    -name '*.js' -print0
}

function compile_0() {
  xargs -0 java -jar "$dir"/third_party/closure/compiler.jar $closure_opts "$@"
}

function lint_0() {
  # Allow JSDoc3 tags not normally recognized by the linter, but be strict<commit_msg>Always build the same input files to a stable output.<commit_after># Copyright 2014 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

dir=$(dirname "$BASH_SOURCE")/..

function calculate_version() {
  cd "$dir"
  # Check git tags for a version number, noting if the sources are dirty.
  if ! git describe --tags --dirty 2>/dev/null; then
    # Fall back to NPM's installed package version, and assume the sources
    # are dirty since the build scripts are being run at all after install.
    npm ls | grep shaka-player | sed -e 's/.*@\(.*\?\) .*/\1-npm-dirty/'
  fi
}

GIT_VERSION=$(calculate_version)

# 'deprecatedAnnotations' controls complaints about @expose, but the new
# @nocollapse annotation does not do the same job for properties.
# So since we can't use the new annotations, we have to ignore complaints
# about the old one.

closure_opts="
  --language_in ECMASCRIPT5
  --language_out ECMASCRIPT5

  --jscomp_error=accessControls
  --jscomp_error=ambiguousFunctionDecl
  --jscomp_error=checkDebuggerStatement
  --jscomp_error=checkRegExp
  --jscomp_error=checkTypes
  --jscomp_error=checkVars
  --jscomp_error=const
  --jscomp_error=constantProperty
  --jscomp_error=deprecated
  --jscomp_error=duplicate
  --jscomp_error=es5Strict
  --jscomp_error=externsValidation
  --jscomp_error=fileoverviewTags
  --jscomp_error=globalThis
  --jscomp_error=internetExplorerChecks
  --jscomp_error=invalidCasts
  --jscomp_error=missingProperties
  --jscomp_error=nonStandardJsDocs
  --jscomp_error=strictModuleDepCheck
  --jscomp_error=suspiciousCode
  --jscomp_error=undefinedNames
  --jscomp_error=undefinedVars
  --jscomp_error=unknownDefines
  --jscomp_error=uselessCode
  --jscomp_error=visibility

  --jscomp_off=deprecatedAnnotations

  --extra_annotation_name=listens
  --extra_annotation_name=exportDoc

  -O ADVANCED
  --generate_exports
  --output_wrapper_file="$dir"/build/wrapper.template.js

  -D COMPILED=true
  -D goog.DEBUG=false
  -D goog.STRICT_MODE_COMPATIBLE=true
  -D goog.ENABLE_DEBUG_LOADER=false
  -D shaka.asserts.ENABLE_ASSERTS=false
  -D shaka.log.MAX_LOG_LEVEL=0
  -D GIT_VERSION='$GIT_VERSION'
"

set -e

function library_sources_0() {
  find \
    "$dir"/lib \
    "$dir"/externs \
    -name '*.js' -print0
}

function test_sources_0() {
  find \
    "$dir"/spec \
    -name '*.js' -print0
}

function closure_sources_0() {
  find \
    "$dir"/third_party/closure \
    -name '*.js' -print0
}

function compile_0() {
  sort -z | xargs -0 \
    java -jar "$dir"/third_party/closure/compiler.jar $closure_opts "$@"
}

function lint_0() {
  # Allow JSDoc3 tags not normally recognized by the linter, but be strict
{'fraction_non_alphanumeric': 0.10403329065300897, 'fraction_numerical': 0.0076824583866837385, 'mean_word_length': 3.9088766692851533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2165679', 'n_tokens_mistral': 2078, 'n_tokens_neox': 2018, 'n_words': 560}