• Home
  • Raw
  • Download

Lines Matching full:out

12 gn gen out/config --ide=json --json-ide-script=../../gn/gn_to_cmake.py
16 gn gen out/config --ide=json
17 python gn/gn_to_cmake.py out/config/project.json
60 def SetVariable(out, variable_name, value): argument
62 out.write('set("')
63 out.write(CMakeStringEscape(variable_name))
64 out.write('" "')
65 out.write(CMakeStringEscape(value))
66 out.write('")\n')
69 def SetVariableList(out, variable_name, values): argument
72 return SetVariable(out, variable_name, "")
74 return SetVariable(out, variable_name, values[0])
75 out.write('list(APPEND "')
76 out.write(CMakeStringEscape(variable_name))
77 out.write('"\n "')
78 out.write('"\n "'.join([CMakeStringEscape(value) for value in values]))
79 out.write('")\n')
95 def SetCurrentTargetProperty(out, property_name, values, sep=''): argument
97 out.write('set_target_properties("${target}" PROPERTIES ')
98 out.write(property_name)
99 out.write(' "')
101 out.write(CMakeStringEscape(value))
102 out.write(sep)
103 out.write('")\n')
233 def WriteAction(out, target, project, sources, synthetic_dependencies): argument
243 SetVariableList(out, outputs_name, outputs)
245 out.write('add_custom_command(OUTPUT ')
246 WriteVariable(out, outputs_name)
247 out.write('\n')
250 out.write(' COMMAND ${CMAKE_COMMAND} -E make_directory "')
251 out.write('" "'.join(map(CMakeStringEscape, output_directories)))
252 out.write('"\n')
256 out.write(' COMMAND python "')
257 out.write(CMakeStringEscape(project.GetAbsolutePath(script)))
258 out.write('"')
260 out.write('\n "')
261 out.write('"\n "'.join(map(CMakeStringEscape, arguments)))
262 out.write('"')
263 out.write('\n')
265 out.write(' DEPENDS ')
267 WriteVariable(out, sources_type_name, ' ')
268 out.write('\n')
272 out.write(' WORKING_DIRECTORY "')
273 out.write(CMakeStringEscape(project.build_path))
274 out.write('"\n')
276 out.write(' COMMENT "Action: ${target}"\n')
278 out.write(' VERBATIM)\n')
294 def WriteActionForEach(out, target, project, sources, synthetic_dependencies): argument
312 SetVariableList(out, outputs_name, outputs)
314 out.write('add_custom_command(OUTPUT ')
315 WriteVariable(out, outputs_name)
316 out.write('\n')
319 out.write(' COMMAND ${CMAKE_COMMAND} -E make_directory "')
320 out.write('" "'.join(map(CMakeStringEscape, output_directories)))
321 out.write('"\n')
326 out.write(' COMMAND python "')
327 out.write(CMakeStringEscape(project.GetAbsolutePath(script)))
328 out.write('"')
330 out.write('\n "')
332 out.write('"\n "'.join(map(CMakeStringEscape, map(expand,arguments))))
333 out.write('"')
334 out.write('\n')
336 out.write(' DEPENDS')
338 WriteVariable(out, sources['input'], ' ')
339 out.write(' "')
340 out.write(CMakeStringEscape(source_abs_path))
341 out.write('"\n')
345 out.write(' WORKING_DIRECTORY "')
346 out.write(CMakeStringEscape(project.build_path))
347 out.write('"\n')
349 out.write(' COMMENT "Action ${target} on ')
350 out.write(CMakeStringEscape(source_abs_path))
351 out.write('"\n')
353 out.write(' VERBATIM)\n')
358 def WriteCopy(out, target, project, sources, synthetic_dependencies): argument
368 SetVariableList(out, outputs_name, outputs)
370 out.write('add_custom_command(OUTPUT ')
371 WriteVariable(out, outputs_name)
372 out.write('\n')
380 out.write(' COMMAND ${CMAKE_COMMAND} -E copy "')
382 out.write(' COMMAND ${CMAKE_COMMAND} -E copy_directory "')
383 out.write(abs_src_path)
384 out.write('" "')
385 out.write(CMakeStringEscape(dst))
386 out.write('"\n')
388 out.write(' DEPENDS ')
390 WriteVariable(out, sources_type_name, ' ')
391 out.write('\n')
393 out.write(' WORKING_DIRECTORY "')
394 out.write(CMakeStringEscape(project.build_path))
395 out.write('"\n')
397 out.write(' COMMENT "Copy ${target}"\n')
399 out.write(' VERBATIM)\n')
404 def WriteCompilerFlags(out, target, project, sources): argument
407 SetCurrentTargetProperty(out, 'LINKER_LANGUAGE', ['C'])
411 SetFilesProperty(out, sources['input'], 'HEADER_FILE_ONLY', ('True',), '')
413 SetFilesProperty(out, sources['other'], 'HEADER_FILE_ONLY', ('True',), '')
417 SetFilesProperty(out, sources['obj'], 'EXTERNAL_OBJECT', ('True',), '')
425 out.write('set_property(TARGET "${target}" ')
426 out.write('APPEND PROPERTY INCLUDE_DIRECTORIES')
428 out.write('\n "')
429 out.write(project.GetAbsolutePath(include_dir))
430 out.write('"')
431 out.write(')\n')
436 SetCurrentTargetProperty(out, 'COMPILE_DEFINITIONS', defines, ';')
457 SetFilesProperty(out, sources['asm'], 'COMPILE_FLAGS', cflags_asm, ' ')
459 SetFilesProperty(out, sources['c'], 'COMPILE_FLAGS', cflags_c, ' ')
461 SetFilesProperty(out, sources['cxx'], 'COMPILE_FLAGS', cflags_cxx, ' ')
463 SetCurrentTargetProperty(out, 'COMPILE_FLAGS', flags, ' ')
468 SetCurrentTargetProperty(out, 'LINK_FLAGS', ldflags, ' ')
479 def WriteSourceVariables(out, target, project): argument
517 SetVariableList(out, sources[source_type], sources_of_type)
521 def WriteTarget(out, target, project): argument
522 out.write('\n#')
523 out.write(target.gn_name)
524 out.write('\n')
531 SetVariable(out, 'target', target.cmake_name)
533 sources = WriteSourceVariables(out, target, project)
537 WriteAction(out, target, project, sources, synthetic_dependencies)
539 WriteActionForEach(out, target, project, sources, synthetic_dependencies)
541 WriteCopy(out, target, project, sources, synthetic_dependencies)
543 out.write(target.cmake_type.command)
544 out.write('("${target}"')
546 out.write(' ')
547 out.write(target.cmake_type.modifier)
549 WriteVariable(out, sources_type_name, ' ')
551 out.write(' DEPENDS')
553 WriteVariable(out, synthetic_dependencie, ' ')
554 out.write(')\n')
557 WriteCompilerFlags(out, target, project, sources)
586 out.write('add_dependencies("${target}"')
588 out.write('\n "')
589 out.write(nonlibrary)
590 out.write('"')
591 out.write(')\n')
598 SetVariableList(out, '${target}__library_directories', library_dirs)
610 out.write('find_library("')
611 out.write(CMakeStringEscape(system_library))
612 out.write('" "')
613 out.write(CMakeStringEscape(external_library))
614 out.write('"')
616 out.write(' PATHS "')
617 WriteVariable(out, '${target}__library_directories')
618 out.write('"')
619 out.write(')\n')
621 out.write('target_link_libraries("${target}"')
623 out.write('\n "')
624 out.write(CMakeStringEscape(library))
625 out.write('"')
627 WriteVariable(out, system_library, '\n "')
628 out.write('"')
629 out.write(')\n')
633 out = open(posixpath.join(project.build_path, 'CMakeLists.txt'), 'w+')
635 out.write('# Generated by gn_to_cmake.py.\n')
636 out.write('cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)\n')
637 out.write('cmake_policy(VERSION 2.8.8)\n\n')
639 out.write('file(WRITE "')
640 out.write(CMakeStringEscape(posixpath.join(project.build_path, "empty.cpp")))
641 out.write('")\n')
645 # gn gen out/config --ide=json --json-ide-script=../../gn/gn_to_cmake.py
647 out.write('execute_process(COMMAND\n')
648 out.write(' ninja -C "')
649 out.write(CMakeStringEscape(project.build_path))
650 out.write('" build.ninja\n')
651 out.write(' RESULT_VARIABLE ninja_result)\n')
652 out.write('if (ninja_result)\n')
653 out.write(' message(WARNING ')
654 out.write('"Regeneration failed running ninja: ${ninja_result}")\n')
655 out.write('endif()\n')
657 out.write('include("')
658 out.write(CMakeStringEscape(extName))
659 out.write('")\n')
660 out.close()
662 out = open(extName, 'w+')
663 out.write('# Generated by gn_to_cmake.py.\n')
664 out.write('cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)\n')
665 out.write('cmake_policy(VERSION 2.8.8)\n')
669 out.write('enable_language(ASM)\n\n')
679 out.write('file(READ "')
681 out.write(CMakeStringEscape(gn_deps_file))
682 out.write('" "gn_deps_string" OFFSET ')
683 out.write(str(len('build.ninja: ')))
684 out.write(')\n')
687 out.write('string(REPLACE " " ";" "gn_deps" ${gn_deps_string})\n')
688 out.write('foreach("gn_dep" ${gn_deps})\n')
689 out.write(' configure_file("')
690 out.write(CMakeStringEscape(project.build_path))
691 out.write('${gn_dep}" "CMakeLists.devnull" COPYONLY)\n')
692 out.write('endforeach("gn_dep")\n')
694 out.write('list(APPEND other_deps "')
695 out.write(CMakeStringEscape(os.path.abspath(__file__)))
696 out.write('")\n')
697 out.write('foreach("other_dep" ${other_deps})\n')
698 out.write(' configure_file("${other_dep}" "CMakeLists.devnull" COPYONLY)\n')
699 out.write('endforeach("other_dep")\n')
702 out.write('\n')
703 WriteTarget(out, Target(target_name, project), project)