| OLD | NEW |
| 1 # Copyright (c) 2013 Google Inc. All rights reserved. | 1 # Copyright (c) 2013 Google Inc. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """cmake output module | 5 """cmake output module |
| 6 | 6 |
| 7 This module is under development and should be considered experimental. | 7 This module is under development and should be considered experimental. |
| 8 | 8 |
| 9 This module produces cmake (2.8.8+) input as its output. One CMakeLists.txt is | 9 This module produces cmake (2.8.8+) input as its output. One CMakeLists.txt is |
| 10 created for each configuration. | 10 created for each configuration. |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 | 210 |
| 211 def WriteVariable(output, variable_name, prepend=None): | 211 def WriteVariable(output, variable_name, prepend=None): |
| 212 if prepend: | 212 if prepend: |
| 213 output.write(prepend) | 213 output.write(prepend) |
| 214 output.write('${') | 214 output.write('${') |
| 215 output.write(variable_name) | 215 output.write(variable_name) |
| 216 output.write('}') | 216 output.write('}') |
| 217 | 217 |
| 218 | 218 |
| 219 class CMakeTargetType: | 219 class CMakeTargetType(object): |
| 220 def __init__(self, command, modifier, property_modifier): | 220 def __init__(self, command, modifier, property_modifier): |
| 221 self.command = command | 221 self.command = command |
| 222 self.modifier = modifier | 222 self.modifier = modifier |
| 223 self.property_modifier = property_modifier | 223 self.property_modifier = property_modifier |
| 224 | 224 |
| 225 | 225 |
| 226 cmake_target_type_from_gyp_target_type = { | 226 cmake_target_type_from_gyp_target_type = { |
| 227 'executable': CMakeTargetType('add_executable', None, 'RUNTIME'), | 227 'executable': CMakeTargetType('add_executable', None, 'RUNTIME'), |
| 228 'static_library': CMakeTargetType('add_library', 'STATIC', 'ARCHIVE'), | 228 'static_library': CMakeTargetType('add_library', 'STATIC', 'ARCHIVE'), |
| 229 'shared_library': CMakeTargetType('add_library', 'SHARED', 'LIBRARY'), | 229 'shared_library': CMakeTargetType('add_library', 'SHARED', 'LIBRARY'), |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 | 457 |
| 458 # CMake gets upset with custom targets with OUTPUT which specify no output. | 458 # CMake gets upset with custom targets with OUTPUT which specify no output. |
| 459 have_copies = any(copy['files'] for copy in copies) | 459 have_copies = any(copy['files'] for copy in copies) |
| 460 if not have_copies: | 460 if not have_copies: |
| 461 output.write('add_custom_target(') | 461 output.write('add_custom_target(') |
| 462 output.write(copy_name) | 462 output.write(copy_name) |
| 463 output.write(')\n') | 463 output.write(')\n') |
| 464 extra_deps.append(copy_name) | 464 extra_deps.append(copy_name) |
| 465 return | 465 return |
| 466 | 466 |
| 467 class Copy: | 467 class Copy(object): |
| 468 def __init__(self, ext, command): | 468 def __init__(self, ext, command): |
| 469 self.cmake_inputs = [] | 469 self.cmake_inputs = [] |
| 470 self.cmake_outputs = [] | 470 self.cmake_outputs = [] |
| 471 self.gyp_inputs = [] | 471 self.gyp_inputs = [] |
| 472 self.gyp_outputs = [] | 472 self.gyp_outputs = [] |
| 473 self.ext = ext | 473 self.ext = ext |
| 474 self.inputs_name = None | 474 self.inputs_name = None |
| 475 self.outputs_name = None | 475 self.outputs_name = None |
| 476 self.command = command | 476 self.command = command |
| 477 | 477 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 if other_srcs_name: | 736 if other_srcs_name: |
| 737 output.write('set_source_files_properties(') | 737 output.write('set_source_files_properties(') |
| 738 WriteVariable(output, other_srcs_name, '') | 738 WriteVariable(output, other_srcs_name, '') |
| 739 output.write(' PROPERTIES HEADER_FILE_ONLY "TRUE")\n') | 739 output.write(' PROPERTIES HEADER_FILE_ONLY "TRUE")\n') |
| 740 | 740 |
| 741 # Output directory | 741 # Output directory |
| 742 target_output_directory = spec.get('product_dir') | 742 target_output_directory = spec.get('product_dir') |
| 743 if target_output_directory is None: | 743 if target_output_directory is None: |
| 744 if target_type in ('executable', 'loadable_module'): | 744 if target_type in ('executable', 'loadable_module'): |
| 745 target_output_directory = generator_default_variables['PRODUCT_DIR'] | 745 target_output_directory = generator_default_variables['PRODUCT_DIR'] |
| 746 elif target_type in ('shared_library'): | 746 elif target_type == 'shared_library': |
| 747 target_output_directory = '${builddir}/lib.${TOOLSET}' | 747 target_output_directory = '${builddir}/lib.${TOOLSET}' |
| 748 elif spec.get('standalone_static_library', False): | 748 elif spec.get('standalone_static_library', False): |
| 749 target_output_directory = generator_default_variables['PRODUCT_DIR'] | 749 target_output_directory = generator_default_variables['PRODUCT_DIR'] |
| 750 else: | 750 else: |
| 751 base_path = gyp.common.RelativePath(os.path.dirname(gyp_file), | 751 base_path = gyp.common.RelativePath(os.path.dirname(gyp_file), |
| 752 options.toplevel_dir) | 752 options.toplevel_dir) |
| 753 target_output_directory = '${obj}.${TOOLSET}' | 753 target_output_directory = '${obj}.${TOOLSET}' |
| 754 target_output_directory = ( | 754 target_output_directory = ( |
| 755 os.path.join(target_output_directory, base_path)) | 755 os.path.join(target_output_directory, base_path)) |
| 756 | 756 |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 arglists.append((target_list, target_dicts, data, | 1134 arglists.append((target_list, target_dicts, data, |
| 1135 params, config_name)) | 1135 params, config_name)) |
| 1136 pool.map(CallGenerateOutputForConfig, arglists) | 1136 pool.map(CallGenerateOutputForConfig, arglists) |
| 1137 except KeyboardInterrupt, e: | 1137 except KeyboardInterrupt, e: |
| 1138 pool.terminate() | 1138 pool.terminate() |
| 1139 raise e | 1139 raise e |
| 1140 else: | 1140 else: |
| 1141 for config_name in config_names: | 1141 for config_name in config_names: |
| 1142 GenerateOutputForConfig(target_list, target_dicts, data, | 1142 GenerateOutputForConfig(target_list, target_dicts, data, |
| 1143 params, config_name) | 1143 params, config_name) |
| OLD | NEW |