| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 'SHARED_INTERMEDIATE_DIR': '${obj}/gen', | 48 'SHARED_INTERMEDIATE_DIR': '${obj}/gen', |
| 49 'PRODUCT_DIR': '${builddir}', | 49 'PRODUCT_DIR': '${builddir}', |
| 50 'RULE_INPUT_PATH': '${RULE_INPUT_PATH}', | 50 'RULE_INPUT_PATH': '${RULE_INPUT_PATH}', |
| 51 'RULE_INPUT_DIRNAME': '${RULE_INPUT_DIRNAME}', | 51 'RULE_INPUT_DIRNAME': '${RULE_INPUT_DIRNAME}', |
| 52 'RULE_INPUT_NAME': '${RULE_INPUT_NAME}', | 52 'RULE_INPUT_NAME': '${RULE_INPUT_NAME}', |
| 53 'RULE_INPUT_ROOT': '${RULE_INPUT_ROOT}', | 53 'RULE_INPUT_ROOT': '${RULE_INPUT_ROOT}', |
| 54 'RULE_INPUT_EXT': '${RULE_INPUT_EXT}', | 54 'RULE_INPUT_EXT': '${RULE_INPUT_EXT}', |
| 55 'CONFIGURATION_NAME': '${configuration}', | 55 'CONFIGURATION_NAME': '${configuration}', |
| 56 } | 56 } |
| 57 | 57 |
| 58 FULL_PATH_VARS = ('${CMAKE_SOURCE_DIR}', '${builddir}', '${obj}') | 58 FULL_PATH_VARS = ('${CMAKE_CURRENT_LIST_DIR}', '${builddir}', '${obj}') |
| 59 | 59 |
| 60 generator_supports_multiple_toolsets = True | 60 generator_supports_multiple_toolsets = True |
| 61 generator_wants_static_library_dependencies_adjusted = True | 61 generator_wants_static_library_dependencies_adjusted = True |
| 62 | 62 |
| 63 COMPILABLE_EXTENSIONS = { | 63 COMPILABLE_EXTENSIONS = { |
| 64 '.c': 'cc', | 64 '.c': 'cc', |
| 65 '.cc': 'cxx', | 65 '.cc': 'cxx', |
| 66 '.cpp': 'cxx', | 66 '.cpp': 'cxx', |
| 67 '.cxx': 'cxx', | 67 '.cxx': 'cxx', |
| 68 '.s': 's', # cc | 68 '.s': 's', # cc |
| (...skipping 27 matching lines...) Expand all Loading... |
| 96 If rel_path is an absolute path it is returned unchanged. | 96 If rel_path is an absolute path it is returned unchanged. |
| 97 Otherwise it is resolved against base_path and normalized. | 97 Otherwise it is resolved against base_path and normalized. |
| 98 If the result is a relative path, it is forced to be relative to the | 98 If the result is a relative path, it is forced to be relative to the |
| 99 CMakeLists.txt. | 99 CMakeLists.txt. |
| 100 """ | 100 """ |
| 101 if os.path.isabs(rel_path): | 101 if os.path.isabs(rel_path): |
| 102 return rel_path | 102 return rel_path |
| 103 if any([rel_path.startswith(var) for var in FULL_PATH_VARS]): | 103 if any([rel_path.startswith(var) for var in FULL_PATH_VARS]): |
| 104 return rel_path | 104 return rel_path |
| 105 # TODO: do we need to check base_path for absolute variables as well? | 105 # TODO: do we need to check base_path for absolute variables as well? |
| 106 return os.path.join('${CMAKE_SOURCE_DIR}', | 106 return os.path.join('${CMAKE_CURRENT_LIST_DIR}', |
| 107 os.path.normpath(os.path.join(base_path, rel_path))) | 107 os.path.normpath(os.path.join(base_path, rel_path))) |
| 108 | 108 |
| 109 | 109 |
| 110 def NormjoinPath(base_path, rel_path): | 110 def NormjoinPath(base_path, rel_path): |
| 111 """Resolves rel_path against base_path and returns the result. | 111 """Resolves rel_path against base_path and returns the result. |
| 112 TODO: what is this really used for? | 112 TODO: what is this really used for? |
| 113 If rel_path begins with '$' it is returned unchanged. | 113 If rel_path begins with '$' it is returned unchanged. |
| 114 Otherwise it is resolved against base_path if relative, then normalized. | 114 Otherwise it is resolved against base_path if relative, then normalized. |
| 115 """ | 115 """ |
| 116 if rel_path.startswith('$') and not rel_path.startswith('${configuration}'): | 116 if rel_path.startswith('$') and not rel_path.startswith('${configuration}'): |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 output.write('\n') | 286 output.write('\n') |
| 287 | 287 |
| 288 output.write(' COMMAND ') | 288 output.write(' COMMAND ') |
| 289 output.write(gyp.common.EncodePOSIXShellList(action['action'])) | 289 output.write(gyp.common.EncodePOSIXShellList(action['action'])) |
| 290 output.write('\n') | 290 output.write('\n') |
| 291 | 291 |
| 292 output.write(' DEPENDS ') | 292 output.write(' DEPENDS ') |
| 293 WriteVariable(output, inputs_name) | 293 WriteVariable(output, inputs_name) |
| 294 output.write('\n') | 294 output.write('\n') |
| 295 | 295 |
| 296 output.write(' WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/') | 296 output.write(' WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/') |
| 297 output.write(path_to_gyp) | 297 output.write(path_to_gyp) |
| 298 output.write('\n') | 298 output.write('\n') |
| 299 | 299 |
| 300 output.write(' COMMENT ') | 300 output.write(' COMMENT ') |
| 301 if 'message' in action: | 301 if 'message' in action: |
| 302 output.write(action['message']) | 302 output.write(action['message']) |
| 303 else: | 303 else: |
| 304 output.write(action_target_name) | 304 output.write(action_target_name) |
| 305 output.write('\n') | 305 output.write('\n') |
| 306 | 306 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 output.write(' COMMAND ') | 391 output.write(' COMMAND ') |
| 392 output.write(gyp.common.EncodePOSIXShellList(rule['action'])) | 392 output.write(gyp.common.EncodePOSIXShellList(rule['action'])) |
| 393 output.write('\n') | 393 output.write('\n') |
| 394 | 394 |
| 395 output.write(' DEPENDS ') | 395 output.write(' DEPENDS ') |
| 396 WriteVariable(output, inputs_name) | 396 WriteVariable(output, inputs_name) |
| 397 output.write(' ') | 397 output.write(' ') |
| 398 output.write(NormjoinPath(path_to_gyp, rule_source)) | 398 output.write(NormjoinPath(path_to_gyp, rule_source)) |
| 399 output.write('\n') | 399 output.write('\n') |
| 400 | 400 |
| 401 # CMAKE_SOURCE_DIR is where the CMakeLists.txt lives. | 401 # CMAKE_CURRENT_LIST_DIR is where the CMakeLists.txt lives. |
| 402 # The cwd is the current build directory. | 402 # The cwd is the current build directory. |
| 403 output.write(' WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/') | 403 output.write(' WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/') |
| 404 output.write(path_to_gyp) | 404 output.write(path_to_gyp) |
| 405 output.write('\n') | 405 output.write('\n') |
| 406 | 406 |
| 407 output.write(' COMMENT ') | 407 output.write(' COMMENT ') |
| 408 if 'message' in rule: | 408 if 'message' in rule: |
| 409 output.write(rule['message']) | 409 output.write(rule['message']) |
| 410 else: | 410 else: |
| 411 output.write(action_name) | 411 output.write(action_name) |
| 412 output.write('\n') | 412 output.write('\n') |
| 413 | 413 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 output.write(' ') | 515 output.write(' ') |
| 516 output.write(dst) | 516 output.write(dst) |
| 517 output.write("\n") | 517 output.write("\n") |
| 518 | 518 |
| 519 output.write('DEPENDS') | 519 output.write('DEPENDS') |
| 520 for copy in (file_copy, dir_copy): | 520 for copy in (file_copy, dir_copy): |
| 521 if copy.inputs_name: | 521 if copy.inputs_name: |
| 522 WriteVariable(output, copy.inputs_name, ' ') | 522 WriteVariable(output, copy.inputs_name, ' ') |
| 523 output.write('\n') | 523 output.write('\n') |
| 524 | 524 |
| 525 output.write('WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/') | 525 output.write('WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/') |
| 526 output.write(path_to_gyp) | 526 output.write(path_to_gyp) |
| 527 output.write('\n') | 527 output.write('\n') |
| 528 | 528 |
| 529 output.write('COMMENT Copying for ') | 529 output.write('COMMENT Copying for ') |
| 530 output.write(target_name) | 530 output.write(target_name) |
| 531 output.write('\n') | 531 output.write('\n') |
| 532 | 532 |
| 533 output.write('VERBATIM\n') | 533 output.write('VERBATIM\n') |
| 534 output.write(')\n') | 534 output.write(')\n') |
| 535 | 535 |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 | 1119 |
| 1120 # The following appears to be as-yet undocumented. | 1120 # The following appears to be as-yet undocumented. |
| 1121 # http://public.kitware.com/Bug/view.php?id=8392 | 1121 # http://public.kitware.com/Bug/view.php?id=8392 |
| 1122 output.write('enable_language(ASM)\n') | 1122 output.write('enable_language(ASM)\n') |
| 1123 # ASM-ATT does not support .S files. | 1123 # ASM-ATT does not support .S files. |
| 1124 # output.write('enable_language(ASM-ATT)\n') | 1124 # output.write('enable_language(ASM-ATT)\n') |
| 1125 | 1125 |
| 1126 if cc: | 1126 if cc: |
| 1127 SetVariable(output, 'CMAKE_ASM_COMPILER', cc) | 1127 SetVariable(output, 'CMAKE_ASM_COMPILER', cc) |
| 1128 | 1128 |
| 1129 SetVariable(output, 'builddir', '${CMAKE_BINARY_DIR}') | 1129 SetVariable(output, 'builddir', '${CMAKE_CURRENT_BINARY_DIR}') |
| 1130 SetVariable(output, 'obj', '${builddir}/obj') | 1130 SetVariable(output, 'obj', '${builddir}/obj') |
| 1131 output.write('\n') | 1131 output.write('\n') |
| 1132 | 1132 |
| 1133 # TODO: Undocumented/unsupported (the CMake Java generator depends on it). | 1133 # TODO: Undocumented/unsupported (the CMake Java generator depends on it). |
| 1134 # CMake by default names the object resulting from foo.c to be foo.c.o. | 1134 # CMake by default names the object resulting from foo.c to be foo.c.o. |
| 1135 # Gyp traditionally names the object resulting from foo.c foo.o. | 1135 # Gyp traditionally names the object resulting from foo.c foo.o. |
| 1136 # This should be irrelevant, but some targets extract .o files from .a | 1136 # This should be irrelevant, but some targets extract .o files from .a |
| 1137 # and depend on the name of the extracted .o files. | 1137 # and depend on the name of the extracted .o files. |
| 1138 output.write('set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)\n') | 1138 output.write('set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)\n') |
| 1139 output.write('set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)\n') | 1139 output.write('set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)\n') |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 arglists.append((target_list, target_dicts, data, | 1212 arglists.append((target_list, target_dicts, data, |
| 1213 params, config_name)) | 1213 params, config_name)) |
| 1214 pool.map(CallGenerateOutputForConfig, arglists) | 1214 pool.map(CallGenerateOutputForConfig, arglists) |
| 1215 except KeyboardInterrupt, e: | 1215 except KeyboardInterrupt, e: |
| 1216 pool.terminate() | 1216 pool.terminate() |
| 1217 raise e | 1217 raise e |
| 1218 else: | 1218 else: |
| 1219 for config_name in config_names: | 1219 for config_name in config_names: |
| 1220 GenerateOutputForConfig(target_list, target_dicts, data, | 1220 GenerateOutputForConfig(target_list, target_dicts, data, |
| 1221 params, config_name) | 1221 params, config_name) |
| OLD | NEW |