Lines Matching refs:out
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')
234 def WriteAction(out, target, project, sources, synthetic_dependencies): argument
244 SetVariableList(out, outputs_name, outputs)
246 out.write('add_custom_command(OUTPUT ')
247 WriteVariable(out, outputs_name)
248 out.write('\n')
251 out.write(' COMMAND ${CMAKE_COMMAND} -E make_directory "')
252 out.write('" "'.join(map(CMakeStringEscape, output_directories)))
253 out.write('"\n')
257 out.write(' COMMAND python "')
258 out.write(CMakeStringEscape(project.GetAbsolutePath(script)))
259 out.write('"')
261 out.write('\n "')
262 out.write('"\n "'.join(map(CMakeStringEscape, arguments)))
263 out.write('"')
264 out.write('\n')
266 out.write(' DEPENDS ')
268 WriteVariable(out, sources_type_name, ' ')
269 out.write('\n')
273 out.write(' WORKING_DIRECTORY "')
274 out.write(CMakeStringEscape(project.build_path))
275 out.write('"\n')
277 out.write(' COMMENT "Action: ${target}"\n')
279 out.write(' VERBATIM)\n')
295 def WriteActionForEach(out, target, project, sources, synthetic_dependencies): argument
313 SetVariableList(out, outputs_name, outputs)
315 out.write('add_custom_command(OUTPUT ')
316 WriteVariable(out, outputs_name)
317 out.write('\n')
320 out.write(' COMMAND ${CMAKE_COMMAND} -E make_directory "')
321 out.write('" "'.join(map(CMakeStringEscape, output_directories)))
322 out.write('"\n')
327 out.write(' COMMAND python "')
328 out.write(CMakeStringEscape(project.GetAbsolutePath(script)))
329 out.write('"')
331 out.write('\n "')
333 out.write('"\n "'.join(map(CMakeStringEscape, map(expand,arguments))))
334 out.write('"')
335 out.write('\n')
337 out.write(' DEPENDS')
339 WriteVariable(out, sources['input'], ' ')
340 out.write(' "')
341 out.write(CMakeStringEscape(source_abs_path))
342 out.write('"\n')
346 out.write(' WORKING_DIRECTORY "')
347 out.write(CMakeStringEscape(project.build_path))
348 out.write('"\n')
350 out.write(' COMMENT "Action ${target} on ')
351 out.write(CMakeStringEscape(source_abs_path))
352 out.write('"\n')
354 out.write(' VERBATIM)\n')
359 def WriteCopy(out, target, project, sources, synthetic_dependencies): argument
369 SetVariableList(out, outputs_name, outputs)
371 out.write('add_custom_command(OUTPUT ')
372 WriteVariable(out, outputs_name)
373 out.write('\n')
381 out.write(' COMMAND ${CMAKE_COMMAND} -E copy "')
383 out.write(' COMMAND ${CMAKE_COMMAND} -E copy_directory "')
384 out.write(abs_src_path)
385 out.write('" "')
386 out.write(CMakeStringEscape(dst))
387 out.write('"\n')
389 out.write(' DEPENDS ')
391 WriteVariable(out, sources_type_name, ' ')
392 out.write('\n')
394 out.write(' WORKING_DIRECTORY "')
395 out.write(CMakeStringEscape(project.build_path))
396 out.write('"\n')
398 out.write(' COMMENT "Copy ${target}"\n')
400 out.write(' VERBATIM)\n')
405 def WriteCompilerFlags(out, target, project, sources): argument
408 SetCurrentTargetProperty(out, 'LINKER_LANGUAGE', ['C'])
412 SetFilesProperty(out, sources['input'], 'HEADER_FILE_ONLY', ('True',), '')
414 SetFilesProperty(out, sources['other'], 'HEADER_FILE_ONLY', ('True',), '')
418 SetFilesProperty(out, sources['obj'], 'EXTERNAL_OBJECT', ('True',), '')
426 out.write('set_property(TARGET "${target}" ')
427 out.write('APPEND PROPERTY INCLUDE_DIRECTORIES')
429 out.write('\n "')
430 out.write(project.GetAbsolutePath(include_dir))
431 out.write('"')
432 out.write(')\n')
437 SetCurrentTargetProperty(out, 'COMPILE_DEFINITIONS', defines, ';')
467 SetFilesProperty(out, sources['asm'], 'COMPILE_FLAGS', cflags_asm, ' ')
469 SetFilesProperty(out, sources['c'], 'COMPILE_FLAGS', cflags_c, ' ')
471 SetFilesProperty(out, sources['cxx'], 'COMPILE_FLAGS', cflags_cxx, ' ')
473 SetFilesProperty(out, sources['objc'], 'COMPILE_FLAGS', cflags_objc, ' ')
475 SetFilesProperty(out, sources['objcc'], 'COMPILE_FLAGS', cflags_objcc, ' ')
477 SetCurrentTargetProperty(out, 'COMPILE_FLAGS', flags, ' ')
482 SetCurrentTargetProperty(out, 'LINK_FLAGS', ldflags, ' ')
493 def WriteSourceVariables(out, target, project): argument
531 SetVariableList(out, sources[source_type], sources_of_type)
535 def WriteTarget(out, target, project): argument
536 out.write('\n#')
537 out.write(target.gn_name)
538 out.write('\n')
545 SetVariable(out, 'target', target.cmake_name)
547 sources = WriteSourceVariables(out, target, project)
551 WriteAction(out, target, project, sources, synthetic_dependencies)
553 WriteActionForEach(out, target, project, sources, synthetic_dependencies)
555 WriteCopy(out, target, project, sources, synthetic_dependencies)
557 out.write(target.cmake_type.command)
558 out.write('("${target}"')
560 out.write(' ')
561 out.write(target.cmake_type.modifier)
563 WriteVariable(out, sources_type_name, ' ')
565 out.write(' DEPENDS')
567 WriteVariable(out, synthetic_dependencie, ' ')
568 out.write(')\n')
571 WriteCompilerFlags(out, target, project, sources)
600 out.write('add_dependencies("${target}"')
602 out.write('\n "')
603 out.write(nonlibrary)
604 out.write('"')
605 out.write(')\n')
613 SetVariableList(out, '${target}__library_directories', library_dirs)
625 out.write('find_library("')
626 out.write(CMakeStringEscape(system_library))
627 out.write('" "')
628 out.write(CMakeStringEscape(external_library))
629 out.write('"')
631 out.write(' PATHS "')
632 WriteVariable(out, '${target}__library_directories')
633 out.write('"')
634 out.write(')\n')
636 out.write('target_link_libraries("${target}"')
638 out.write('\n "')
639 out.write(CMakeStringEscape(library))
640 out.write('"')
642 WriteVariable(out, system_library, '\n "')
643 out.write('"')
644 out.write(')\n')
648 out = open(posixpath.join(project.build_path, 'CMakeLists.txt'), 'w+')
650 out.write('# Generated by gn_to_cmake.py.\n')
651 out.write('cmake_minimum_required(VERSION 3.7 FATAL_ERROR)\n')
652 out.write('cmake_policy(VERSION 3.7)\n')
653 out.write('project(Skia)\n\n')
655 out.write('file(WRITE "')
656 out.write(CMakeStringEscape(posixpath.join(project.build_path, "empty.cpp")))
657 out.write('")\n')
663 out.write('execute_process(COMMAND\n')
664 out.write(' ninja -C "')
665 out.write(CMakeStringEscape(project.build_path))
666 out.write('" build.ninja\n')
667 out.write(' RESULT_VARIABLE ninja_result)\n')
668 out.write('if (ninja_result)\n')
669 out.write(' message(WARNING ')
670 out.write('"Regeneration failed running ninja: ${ninja_result}")\n')
671 out.write('endif()\n')
673 out.write('include("')
674 out.write(CMakeStringEscape(extName))
675 out.write('")\n')
677 out.write('include_directories(SYSTEM $ENV{EMSDK}/upstream/emscripten/system/include/)\n')
678 out.close()
680 out = open(extName, 'w+')
681 out.write('# Generated by gn_to_cmake.py.\n')
682 out.write('cmake_minimum_required(VERSION 3.7 FATAL_ERROR)\n')
683 out.write('cmake_policy(VERSION 3.7)\n')
687 out.write('enable_language(ASM)\n\n')
697 out.write('file(READ "')
699 out.write(CMakeStringEscape(gn_deps_file))
700 out.write('" "gn_deps_string" OFFSET ')
701 out.write(str(len('build.ninja: ')))
702 out.write(')\n')
705 out.write('string(REPLACE " " ";" "gn_deps" ${gn_deps_string})\n')
706 out.write('foreach("gn_dep" ${gn_deps})\n')
707 out.write(' configure_file("')
708 out.write(CMakeStringEscape(project.build_path))
709 out.write('${gn_dep}" "CMakeLists.devnull" COPYONLY)\n')
710 out.write('endforeach("gn_dep")\n')
712 out.write('list(APPEND other_deps "')
713 out.write(CMakeStringEscape(os.path.abspath(__file__)))
714 out.write('")\n')
715 out.write('foreach("other_dep" ${other_deps})\n')
716 out.write(' configure_file("${other_dep}" "CMakeLists.devnull" COPYONLY)\n')
717 out.write('endforeach("other_dep")\n')
720 out.write('\n')
721 WriteTarget(out, Target(target_name, project), project)