# -*- python -*-
# Copyright 2011 The Native Client Authors.  All rights reserved.
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE file.

# A way to build the PPAPI tests as a trusted plugin to validate directly
# against Chrome on Linux using these arguments:
# --register-pepper-plugins=\
#   "/path/to/libppapi_tests_<ARCH>.so;application/x-nacl"
# --enable-pepper-testing \
# http://localhost:5103/scons-out/nacl-x86-../staging/test_case.html
# Tip: you can verify that the plugin was loaded by navigating to about:plugins
# in Chromium.

# Also see nacl.scons for building/running (a subset of) these tests in NaCl.

Import('env')

if env.Bit('linux'):
  env['COMPONENT_STATIC'] = False  # Build a .so, not a .a

  # Adjust CCFLAGS to match the more forgiving standards used in the Chromium
  # PPAPI tests.
  env.FilterOut(CCFLAGS=['-Werror', '-pedantic'])
  env.Append(CCFLAGS=['-Wno-unused-parameter',
                      '-Wno-missing-field-initializers',
                      '-Wall'])
  ppapi_tests_trusted = 'libppapi_tests_%s.so' % env.get('TARGET_FULLARCH')

  libppapi_tests_so = env.ComponentLibrary(
                          ppapi_tests_trusted,
                          Glob('${SOURCE_ROOT}/ppapi/tests/*.cc'),
                          EXTRA_LIBS=['ppapi_cpp'],
                          no_import_lib=True)

  env.Publish(ppapi_tests_trusted, 'run',
              ['${SOURCE_ROOT}/ppapi/tests/test_url_loader_data/*'],
              subdir='test_url_loader_data')

  env.Publish(ppapi_tests_trusted, 'run',
              [libppapi_tests_so,
               '${SOURCE_ROOT}/ppapi/tests/test_case.html',
               'test_case.nmf',
               '${SOURCE_ROOT}/ppapi/tests/test_image_data',
               '${SOURCE_ROOT}/ppapi/tests/test_page.css'])