mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add unittests target to the binary distribution (issue #1632)
- Move all tests from the top-level directory to tests/. - Move files shared by cefclient and unittests to tests/shared/. - Add a fused (single header/source file) version of gtest in tests/gtest/ with associated CMake configuration. - Test-only headers are now exposed in include/test/. Unit test targets must define UNIT_TEST in order to access them. - Replace usage of USING_CEF_SHARED with WRAPPING_CEF_SHARED for clarity (only the libcef_dll_wrapper target should define it). - Remove the RENAME_DIRECTORY CMake macro which is no longer used. - Remove C++11 usage from unittests sources for compatibility with the binary distribution configuration. - Windows: Fix build errors due to chrome_elf.dll and imm32.lib missing from the CMake configuration.
This commit is contained in:
@ -148,15 +148,44 @@ def create_readme():
|
||||
if not options.quiet:
|
||||
sys.stdout.write('Creating README.TXT file.\n')
|
||||
|
||||
def create_fuzed_gtest(tests_dir):
|
||||
""" Generate a fuzed version of gtest and build the expected directory structure. """
|
||||
src_gtest_dir = os.path.join(src_dir, 'testing', 'gtest')
|
||||
run('%s fuse_gtest_files.py \"%s\"' % (sys.executable, tests_dir),
|
||||
os.path.join(src_gtest_dir, 'scripts'))
|
||||
|
||||
if not options.quiet:
|
||||
sys.stdout.write('Building gtest directory structure.\n')
|
||||
|
||||
target_gtest_dir = os.path.join(tests_dir, 'gtest')
|
||||
gtest_header = os.path.join(target_gtest_dir, 'gtest.h')
|
||||
gtest_cpp = os.path.join(target_gtest_dir, 'gtest-all.cc')
|
||||
|
||||
if not os.path.exists(gtest_header):
|
||||
raise Exception('Generated file not found: %s' % gtest_header)
|
||||
if not os.path.exists(gtest_cpp):
|
||||
raise Exception('Generated file not found: %s' % gtest_cpp)
|
||||
|
||||
# gtest header file at tests/gtest/include/gtest/gtest.h
|
||||
target_gtest_header_dir = os.path.join(target_gtest_dir, 'include', 'gtest')
|
||||
make_dir(target_gtest_header_dir, options.quiet)
|
||||
move_file(gtest_header, target_gtest_header_dir, options.quiet)
|
||||
|
||||
# gtest source file at tests/gtest/src/gtest-all.cc
|
||||
target_gtest_cpp_dir = os.path.join(target_gtest_dir, 'src')
|
||||
make_dir(target_gtest_cpp_dir, options.quiet)
|
||||
move_file(gtest_cpp, target_gtest_cpp_dir, options.quiet)
|
||||
|
||||
# gtest LICENSE file at tests/gtest/LICENSE
|
||||
copy_file(os.path.join(src_gtest_dir, 'LICENSE'), target_gtest_dir, options.quiet)
|
||||
|
||||
# CEF README file at tests/gtest/README.cef
|
||||
copy_file(os.path.join(cef_dir, 'tests', 'gtest', 'README.cef.in'),
|
||||
os.path.join(target_gtest_dir, 'README.cef'), options.quiet)
|
||||
|
||||
def transfer_gypi_files(src_dir, gypi_paths, gypi_path_prefix, dst_dir, quiet):
|
||||
""" Transfer files from one location to another. """
|
||||
for path in gypi_paths:
|
||||
# skip gyp includes
|
||||
if path[:2] == '<@':
|
||||
continue
|
||||
# skip test files
|
||||
if path.find('/test/') >= 0:
|
||||
continue
|
||||
src = os.path.join(src_dir, path)
|
||||
dst = os.path.join(dst_dir, path.replace(gypi_path_prefix, ''))
|
||||
dst_path = os.path.dirname(dst)
|
||||
@ -469,14 +498,36 @@ if mode == 'standard' or mode == 'minimal':
|
||||
variables, options.quiet)
|
||||
|
||||
if mode == 'standard':
|
||||
# create the cefclient directory
|
||||
cefclient_dir = os.path.join(output_dir, 'cefclient')
|
||||
# create the tests directory
|
||||
tests_dir = os.path.join(output_dir, 'tests')
|
||||
make_dir(tests_dir, options.quiet)
|
||||
|
||||
# create the tests/shared directory
|
||||
shared_dir = os.path.join(tests_dir, 'shared')
|
||||
make_dir(shared_dir, options.quiet)
|
||||
|
||||
# create the tests/cefclient directory
|
||||
cefclient_dir = os.path.join(tests_dir, 'cefclient')
|
||||
make_dir(cefclient_dir, options.quiet)
|
||||
|
||||
# create the cefsimple directory
|
||||
cefsimple_dir = os.path.join(output_dir, 'cefsimple')
|
||||
# create the tests/cefsimple directory
|
||||
cefsimple_dir = os.path.join(tests_dir, 'cefsimple')
|
||||
make_dir(cefsimple_dir, options.quiet)
|
||||
|
||||
# create the tests/unittests directory
|
||||
unittests_dir = os.path.join(tests_dir, 'unittests')
|
||||
make_dir(unittests_dir, options.quiet)
|
||||
|
||||
# transfer common shared files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['shared_sources_browser'], \
|
||||
'tests/shared/', shared_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['shared_sources_common'], \
|
||||
'tests/shared/', shared_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['shared_sources_renderer'], \
|
||||
'tests/shared/', shared_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['shared_sources_resources'], \
|
||||
'tests/shared/', shared_dir, options.quiet)
|
||||
|
||||
# transfer common cefclient files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_browser'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
@ -491,6 +542,13 @@ if mode == 'standard':
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_common'], \
|
||||
'tests/cefsimple/', cefsimple_dir, options.quiet)
|
||||
|
||||
# transfer common unittests files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['unittests_sources_common'], \
|
||||
'tests/unittests/', unittests_dir, options.quiet)
|
||||
|
||||
# create the fuzed gtest version
|
||||
create_fuzed_gtest(tests_dir)
|
||||
|
||||
# process cmake templates
|
||||
process_cmake_template(os.path.join(cef_dir, 'tests', 'cefclient', 'CMakeLists.txt.in'), \
|
||||
os.path.join(cefclient_dir, 'CMakeLists.txt'), \
|
||||
@ -498,15 +556,18 @@ if mode == 'standard':
|
||||
process_cmake_template(os.path.join(cef_dir, 'tests', 'cefsimple', 'CMakeLists.txt.in'), \
|
||||
os.path.join(cefsimple_dir, 'CMakeLists.txt'), \
|
||||
variables, options.quiet)
|
||||
process_cmake_template(os.path.join(cef_dir, 'tests', 'gtest', 'CMakeLists.txt.in'), \
|
||||
os.path.join(tests_dir, 'gtest', 'CMakeLists.txt'), \
|
||||
variables, options.quiet)
|
||||
process_cmake_template(os.path.join(cef_dir, 'tests', 'unittests', 'CMakeLists.txt.in'), \
|
||||
os.path.join(unittests_dir, 'CMakeLists.txt'), \
|
||||
variables, options.quiet)
|
||||
|
||||
# transfer gyp files
|
||||
paths_gypi = os.path.join(cef_dir, 'cef_paths2.gypi')
|
||||
data = read_file(paths_gypi)
|
||||
data = data.replace('tests/cefclient/', 'cefclient/')
|
||||
data = data.replace('tests/cefsimple/', 'cefsimple/')
|
||||
write_file(os.path.join(output_dir, 'cef_paths2.gypi'), data)
|
||||
# transfer gypi files
|
||||
copy_file(os.path.join(cef_dir, 'cef_paths.gypi'), \
|
||||
os.path.join(output_dir, 'cef_paths.gypi'), options.quiet)
|
||||
copy_file(os.path.join(cef_dir, 'cef_paths2.gypi'), \
|
||||
os.path.join(output_dir, 'cef_paths2.gypi'), options.quiet)
|
||||
|
||||
if platform == 'windows':
|
||||
binaries = [
|
||||
@ -606,6 +667,10 @@ if platform == 'windows':
|
||||
mode, output_dir, options.quiet)
|
||||
|
||||
if mode == 'standard':
|
||||
# transfer shared files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['shared_sources_win'], \
|
||||
'tests/shared/', shared_dir, options.quiet)
|
||||
|
||||
# transfer cefclient files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_win'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
@ -614,6 +679,12 @@ if platform == 'windows':
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_win'], \
|
||||
'tests/cefsimple/', cefsimple_dir, options.quiet)
|
||||
|
||||
# transfer unittests files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['unittests_sources_win'], \
|
||||
'tests/unittests/', unittests_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['unittests_sources_views'], \
|
||||
'tests/unittests/', unittests_dir, options.quiet)
|
||||
|
||||
if not options.nodocs:
|
||||
# generate doc files
|
||||
os.popen('make_cppdocs.bat '+cef_rev)
|
||||
@ -683,17 +754,19 @@ elif platform == 'macosx':
|
||||
mode, output_dir, options.quiet)
|
||||
|
||||
if mode == 'standard':
|
||||
# transfer shared files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['shared_sources_mac'], \
|
||||
'tests/shared/', shared_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['shared_sources_mac_helper'], \
|
||||
'tests/shared/', shared_dir, options.quiet)
|
||||
|
||||
# transfer cefclient files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_mac'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_mac_helper'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_bundle_resources_mac'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
|
||||
# transfer cefclient/resources/mac files
|
||||
copy_dir(os.path.join(cef_dir, 'tests/cefclient/resources/mac/'), \
|
||||
os.path.join(output_dir, 'cefclient/resources/mac/'), \
|
||||
copy_dir(os.path.join(cef_dir, 'tests/cefclient/resources/mac'), \
|
||||
os.path.join(cefclient_dir, 'resources/mac'), \
|
||||
options.quiet)
|
||||
|
||||
# transfer cefsimple files
|
||||
@ -701,11 +774,21 @@ elif platform == 'macosx':
|
||||
'tests/cefsimple/', cefsimple_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_mac_helper'], \
|
||||
'tests/cefsimple/', cefsimple_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefsimple_bundle_resources_mac'], \
|
||||
'tests/cefsimple/', cefsimple_dir, options.quiet)
|
||||
|
||||
# transfer cefsimple/mac files
|
||||
copy_dir(os.path.join(cef_dir, 'tests/cefsimple/mac/'), os.path.join(output_dir, 'cefsimple/mac/'), \
|
||||
copy_dir(os.path.join(cef_dir, 'tests/cefsimple/mac'), \
|
||||
os.path.join(cefsimple_dir, 'mac'), \
|
||||
options.quiet)
|
||||
|
||||
# transfer unittests files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['unittests_sources_mac'], \
|
||||
'tests/unittests/', unittests_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['unittests_sources_mac_helper'], \
|
||||
'tests/unittests/', unittests_dir, options.quiet)
|
||||
|
||||
# transfer unittests/resources/mac files
|
||||
copy_dir(os.path.join(cef_dir, 'tests/unittests/resources/mac'), \
|
||||
os.path.join(unittests_dir, 'resources/mac'), \
|
||||
options.quiet)
|
||||
|
||||
elif platform == 'linux':
|
||||
@ -771,6 +854,10 @@ elif platform == 'linux':
|
||||
mode, output_dir, options.quiet)
|
||||
|
||||
if mode == 'standard':
|
||||
# transfer shared files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['shared_sources_linux'], \
|
||||
'tests/shared/', shared_dir, options.quiet)
|
||||
|
||||
# transfer cefclient files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_linux'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
@ -779,6 +866,12 @@ elif platform == 'linux':
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_linux'], \
|
||||
'tests/cefsimple/', cefsimple_dir, options.quiet)
|
||||
|
||||
# transfer unittests files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['unittests_sources_linux'], \
|
||||
'tests/unittests/', unittests_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['unittests_sources_views'], \
|
||||
'tests/unittests/', unittests_dir, options.quiet)
|
||||
|
||||
if not options.noarchive:
|
||||
# create an archive for each output directory
|
||||
archive_format = os.getenv('CEF_ARCHIVE_FORMAT', 'zip')
|
||||
|
Reference in New Issue
Block a user