Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1501)

Side by Side Diff: site_scons/site_tools/component_builders.py

Issue 10231: Adding in new solution builder pattern. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/resources/SConscript ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python2.4 1 #!/usr/bin/python2.4
2 # Copyright 2008, Google Inc. 2 # Copyright 2008, Google Inc.
3 # All rights reserved. 3 # All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 310
311 # Install program and resources 311 # Install program and resources
312 all_outputs = [] 312 all_outputs = []
313 components = _RetrieveComponents(prog_name) 313 components = _RetrieveComponents(prog_name)
314 for resource, dest_dir in env.get('COMPONENT_TEST_RESOURCES').items(): 314 for resource, dest_dir in env.get('COMPONENT_TEST_RESOURCES').items():
315 all_outputs += env.ReplicatePublished(dest_dir, components, resource) 315 all_outputs += env.ReplicatePublished(dest_dir, components, resource)
316 316
317 # Add installed program and resources to the alias 317 # Add installed program and resources to the alias
318 env.Alias(prog_name, all_outputs) 318 env.Alias(prog_name, all_outputs)
319 319
320 # Add an alias for running the test in the test directory, if there's a test 320 # Add target properties
321 # command line. 321 env.SetTargetProperty(
322 if env.get('COMPONENT_TEST_CMDLINE'): 322 prog_name,
323 # Test program is the first run resource we replicated. 323 # The copy of the program we care about is the one in the tests dir
324 test_program = env.ReplicatePublished('$TESTS_DIR', prog_name, 'run') 324 EXE='$TESTS_DIR/$PROGRAM_NAME',
325 RUN_CMDLINE='$COMPONENT_TEST_CMDLINE',
326 RUN_DIR='$TESTS_DIR',
327 TARGET_PATH='$TESTS_DIR/$PROGRAM_NAME',
328 )
329
330 # Add an alias for running the test in the test directory, if the test is
331 # runnable and has a test command line.
332 if env.get('COMPONENT_TEST_RUNNABLE') and env.get('COMPONENT_TEST_CMDLINE'):
325 env.Replace( 333 env.Replace(
326 COMMAND_OUTPUT_CMDLINE=env['COMPONENT_TEST_CMDLINE'], 334 COMMAND_OUTPUT_CMDLINE=env['COMPONENT_TEST_CMDLINE'],
327 COMMAND_OUTPUT_RUN_DIR='$TESTS_DIR', 335 COMMAND_OUTPUT_RUN_DIR='$TESTS_DIR',
328 ) 336 )
329 test_out_name = '$TEST_OUTPUT_DIR/${PROGRAM_BASENAME}.out.txt' 337 test_out_name = '$TEST_OUTPUT_DIR/${PROGRAM_BASENAME}.out.txt'
330 if (env.GetOption('component_test_retest') 338 if (env.GetOption('component_test_retest')
331 and env.File(test_out_name).exists()): 339 and env.File(test_out_name).exists()):
332 # Delete old test results, so test will rerun. 340 # Delete old test results, so test will rerun.
333 env.Execute(SCons.Script.Delete(test_out_name)) 341 env.Execute(SCons.Script.Delete(test_out_name))
334 342
335 # Set timeout based on test size 343 # Set timeout based on test size
336 timeout = env.get('COMPONENT_TEST_TIMEOUT') 344 timeout = env.get('COMPONENT_TEST_TIMEOUT')
337 if type(timeout) is dict: 345 if type(timeout) is dict:
338 timeout = timeout.get(env.get('COMPONENT_TEST_SIZE')) 346 timeout = timeout.get(env.get('COMPONENT_TEST_SIZE'))
339 if timeout: 347 if timeout:
340 env['COMMAND_OUTPUT_TIMEOUT'] = timeout 348 env['COMMAND_OUTPUT_TIMEOUT'] = timeout
341 349
350 # Test program is the first run resource we replicated. (Duplicate
351 # replicate is not harmful, and is a handy way to pick out the correct
352 # file from all those we replicated above.)
353 test_program = env.ReplicatePublished('$TESTS_DIR', prog_name, 'run')
354
342 # Run the test. Note that we need to refer to the file by name, so that 355 # Run the test. Note that we need to refer to the file by name, so that
343 # SCons will recreate the file node after we've deleted it; if we used the 356 # SCons will recreate the file node after we've deleted it; if we used the
344 # env.File() we created in the if statement above, SCons would still think 357 # env.File() we created in the if statement above, SCons would still think
345 # it exists and not rerun the test. 358 # it exists and not rerun the test.
346 test_out = env.CommandOutput(test_out_name, test_program) 359 test_out = env.CommandOutput(test_out_name, test_program)
347 360
348 # Running the test requires the test and its libs copied to the tests dir 361 # Running the test requires the test and its libs copied to the tests dir
349 env.Depends(test_out, all_outputs) 362 env.Depends(test_out, all_outputs)
350 env.ComponentTestOutput('run_' + prog_name, test_out) 363 env.ComponentTestOutput('run_' + prog_name, test_out)
351 364
352 # Add target properties 365 # Add target properties
353 env.SetTargetProperty( 366 env.SetTargetProperty(prog_name, RUN_TARGET='run_' + prog_name)
354 prog_name,
355 # The copy of the program we care about is the one in the tests dir
356 EXE='$TESTS_DIR/$PROGRAM_NAME',
357 RUN_TARGET='run_' + prog_name,
358 RUN_CMDLINE='$COMPONENT_TEST_CMDLINE',
359 RUN_DIR='$TESTS_DIR',
360 TARGET_PATH='$TESTS_DIR/$PROGRAM_NAME',
361 )
362
363 367
364 def ComponentTestProgram(self, prog_name, *args, **kwargs): 368 def ComponentTestProgram(self, prog_name, *args, **kwargs):
365 """Pseudo-builder for test program to handle platform-dependent type. 369 """Pseudo-builder for test program to handle platform-dependent type.
366 370
367 Args: 371 Args:
368 self: Environment in which we were called. 372 self: Environment in which we were called.
369 prog_name: Test program name. 373 prog_name: Test program name.
370 args: Positional arguments. 374 args: Positional arguments.
371 kwargs: Keyword arguments. 375 kwargs: Keyword arguments.
372 376
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 # have transitioned to LIB_DIR 531 # have transitioned to LIB_DIR
528 COMPONENT_LIBRARY_DIR='$LIB_DIR', 532 COMPONENT_LIBRARY_DIR='$LIB_DIR',
529 STAGING_DIR='$TARGET_ROOT/staging', 533 STAGING_DIR='$TARGET_ROOT/staging',
530 TESTS_DIR='$TARGET_ROOT/tests', 534 TESTS_DIR='$TARGET_ROOT/tests',
531 TEST_OUTPUT_DIR='$TARGET_ROOT/test_output', 535 TEST_OUTPUT_DIR='$TARGET_ROOT/test_output',
532 # Default command line for a test is just the name of the file. 536 # Default command line for a test is just the name of the file.
533 # TODO(rspangler): Why doesn't the following work: 537 # TODO(rspangler): Why doesn't the following work:
534 # COMPONENT_TEST_CMDLINE='${SOURCE.abspath}', 538 # COMPONENT_TEST_CMDLINE='${SOURCE.abspath}',
535 # (it generates a SCons error) 539 # (it generates a SCons error)
536 COMPONENT_TEST_CMDLINE='${PROGRAM_NAME}', 540 COMPONENT_TEST_CMDLINE='${PROGRAM_NAME}',
541 # Component tests are runnable by default.
542 COMPONENT_TEST_RUNNABLE=True,
537 # Default test size is large 543 # Default test size is large
538 COMPONENT_TEST_SIZE='large', 544 COMPONENT_TEST_SIZE='large',
539 # Default timeouts for component tests 545 # Default timeouts for component tests
540 COMPONENT_TEST_TIMEOUT={'large': 900, 'medium': 450, 'small': 180}, 546 COMPONENT_TEST_TIMEOUT={'large': 900, 'medium': 450, 'small': 180},
541 # Tests are enabled by default 547 # Tests are enabled by default
542 COMPONENT_TEST_ENABLED=True, 548 COMPONENT_TEST_ENABLED=True,
543 # Static linking is a sensible default 549 # Static linking is a sensible default
544 COMPONENT_STATIC=True, 550 COMPONENT_STATIC=True,
545 # Don't publish libraries to the staging dir by themselves by default. 551 # Don't publish libraries to the staging dir by themselves by default.
546 COMPONENT_LIBRARY_PUBLISH=False, 552 COMPONENT_LIBRARY_PUBLISH=False,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 AddTargetGroup('all_libraries', 'libraries can be built') 609 AddTargetGroup('all_libraries', 'libraries can be built')
604 AddTargetGroup('all_programs', 'programs can be built') 610 AddTargetGroup('all_programs', 'programs can be built')
605 AddTargetGroup('all_test_programs', 'tests can be built') 611 AddTargetGroup('all_test_programs', 'tests can be built')
606 AddTargetGroup('all_packages', 'packages can be built') 612 AddTargetGroup('all_packages', 'packages can be built')
607 AddTargetGroup('run_all_tests', 'tests can be run') 613 AddTargetGroup('run_all_tests', 'tests can be run')
608 AddTargetGroup('run_disabled_tests', 'tests are disabled') 614 AddTargetGroup('run_disabled_tests', 'tests are disabled')
609 AddTargetGroup('run_small_tests', 'small tests can be run') 615 AddTargetGroup('run_small_tests', 'small tests can be run')
610 AddTargetGroup('run_medium_tests', 'medium tests can be run') 616 AddTargetGroup('run_medium_tests', 'medium tests can be run')
611 AddTargetGroup('run_large_tests', 'large tests can be run') 617 AddTargetGroup('run_large_tests', 'large tests can be run')
612 618
OLDNEW
« no previous file with comments | « chrome/app/resources/SConscript ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698