├── .clang-format ├── .editorconfig ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .style.yapf ├── AUTHORS ├── LICENSE ├── OWNERS ├── README.md ├── build ├── build_aix.ninja.template ├── build_haiku.ninja.template ├── build_linux.ninja.template ├── build_mac.ninja.template ├── build_openbsd.ninja.template ├── build_win.ninja.template ├── build_zos.ninja.template ├── full_test.py └── gen.py ├── docs ├── cross_compiles.md ├── faq.md ├── language.md ├── quick_start.md ├── reference.md ├── standalone.md └── style_guide.md ├── examples ├── ios │ ├── .gitignore │ ├── .gn │ ├── BUILD.gn │ ├── app │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── BUILD.gn │ │ ├── Bar.swift │ │ ├── Baz.swift │ │ ├── Foo-Bridging-Header.h │ │ ├── Foo.swift │ │ ├── FooWrapper.swift │ │ ├── SceneDelegate.h │ │ ├── SceneDelegate.m │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ ├── main.m │ │ └── resources │ │ │ ├── Info.plist │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ ├── build │ │ ├── BUILD.gn │ │ ├── BUILDCONFIG.gn │ │ ├── config │ │ │ └── ios │ │ │ │ ├── BUILD.gn │ │ │ │ ├── bundle_identifier_prefix.gni │ │ │ │ ├── deployment_target.gni │ │ │ │ ├── resources │ │ │ │ ├── Entitlements-Simulated.plist │ │ │ │ ├── Info.plist │ │ │ │ └── compiler-Info.plist │ │ │ │ ├── scripts │ │ │ │ ├── compile_storyboard.py │ │ │ │ ├── find_app_identifier_prefix.py │ │ │ │ ├── generate_umbrella_header.py │ │ │ │ ├── merge_plist.py │ │ │ │ └── sdk_info.py │ │ │ │ ├── sdk_info.gni │ │ │ │ └── templates │ │ │ │ ├── ios_app_bundle.gni │ │ │ │ ├── ios_binary_bundle.gni │ │ │ │ ├── ios_framework_bundle.gni │ │ │ │ ├── merge_plist.gni │ │ │ │ └── storyboards.gni │ │ └── toolchain │ │ │ ├── apple │ │ │ └── swiftc.py │ │ │ ├── ios │ │ │ └── BUILD.gn │ │ │ └── mac │ │ │ └── BUILD.gn │ ├── host │ │ ├── BUILD.gn │ │ └── main.cc │ └── shared │ │ ├── BUILD.gn │ │ ├── hello_shared.h │ │ └── hello_shared.m ├── rust_example │ ├── .gn │ ├── BUILD.gn │ ├── BUILDCONFIG.gn │ ├── README.txt │ ├── build │ │ └── BUILD.gn │ └── hello_world │ │ ├── bar │ │ └── src │ │ │ ├── BUILD.gn │ │ │ └── lib.rs │ │ ├── foo │ │ └── src │ │ │ ├── BUILD.gn │ │ │ └── lib.rs │ │ └── src │ │ ├── BUILD.gn │ │ └── main.rs └── simple_build │ ├── .gn │ ├── BUILD.gn │ ├── README.md │ ├── build │ ├── BUILD.gn │ ├── BUILDCONFIG.gn │ └── toolchain │ │ └── BUILD.gn │ ├── hello.cc │ ├── hello_shared.cc │ ├── hello_shared.h │ ├── hello_static.cc │ ├── hello_static.h │ └── tutorial │ ├── README.md │ └── tutorial.cc ├── infra ├── README.recipes.md ├── config │ ├── generated │ │ ├── commit-queue.cfg │ │ ├── cr-buildbucket.cfg │ │ ├── luci-logdog.cfg │ │ ├── luci-milo.cfg │ │ ├── luci-scheduler.cfg │ │ ├── project.cfg │ │ └── realms.cfg │ ├── main.star │ └── recipes.cfg ├── recipe_modules │ ├── macos_sdk │ │ ├── __init__.py │ │ ├── api.py │ │ └── examples │ │ │ ├── full.expected │ │ │ ├── linux.json │ │ │ ├── mac.json │ │ │ └── win.json │ │ │ └── full.py │ ├── target │ │ ├── __init__.py │ │ ├── api.py │ │ └── examples │ │ │ ├── full.expected │ │ │ ├── linux.json │ │ │ ├── mac.json │ │ │ └── win.json │ │ │ └── full.py │ └── windows_sdk │ │ ├── __init__.py │ │ ├── api.py │ │ └── examples │ │ ├── full.expected │ │ ├── linux.json │ │ ├── mac.json │ │ └── win.json │ │ └── full.py ├── recipes.py └── recipes │ ├── gn.expected │ ├── ci_linux.json │ ├── ci_mac.json │ ├── ci_win.json │ ├── cipd_exists.json │ ├── cipd_register.json │ ├── cq_linux.json │ ├── cq_mac.json │ └── cq_win.json │ └── gn.py ├── misc ├── emacs │ ├── .gitignore │ └── gn-mode.el ├── help_as_html.py ├── tm │ ├── GN.tmLanguage │ └── GN.tmPreferences └── vim │ ├── README.md │ ├── autoload │ └── gn.vim │ ├── ftdetect │ └── gnfiletype.vim │ ├── ftplugin │ └── gn.vim │ ├── gn-format.py │ └── syntax │ └── gn.vim ├── src ├── base │ ├── atomic_ref_count.h │ ├── command_line.cc │ ├── command_line.h │ ├── compiler_specific.h │ ├── containers │ │ ├── circular_deque.h │ │ ├── flat_map.h │ │ ├── flat_set.h │ │ ├── flat_tree.h │ │ ├── queue.h │ │ ├── span.h │ │ ├── stack.h │ │ └── vector_buffer.h │ ├── environment.cc │ ├── environment.h │ ├── files │ │ ├── file.cc │ │ ├── file.h │ │ ├── file_enumerator.cc │ │ ├── file_enumerator.h │ │ ├── file_enumerator_posix.cc │ │ ├── file_enumerator_win.cc │ │ ├── file_path.cc │ │ ├── file_path.h │ │ ├── file_path_constants.cc │ │ ├── file_posix.cc │ │ ├── file_util.cc │ │ ├── file_util.h │ │ ├── file_util_linux.cc │ │ ├── file_util_posix.cc │ │ ├── file_util_win.cc │ │ ├── file_win.cc │ │ ├── platform_file.h │ │ ├── scoped_file.cc │ │ ├── scoped_file.h │ │ ├── scoped_temp_dir.cc │ │ └── scoped_temp_dir.h │ ├── gtest_prod_util.h │ ├── json │ │ ├── json_parser.cc │ │ ├── json_parser.h │ │ ├── json_reader.cc │ │ ├── json_reader.h │ │ ├── json_value_converter.cc │ │ ├── json_value_converter.h │ │ ├── json_writer.cc │ │ ├── json_writer.h │ │ ├── string_escape.cc │ │ └── string_escape.h │ ├── logging.cc │ ├── logging.h │ ├── mac │ │ ├── bundle_locations.h │ │ ├── mac_logging.h │ │ ├── mac_logging.mm │ │ ├── scoped_cftyperef.h │ │ └── scoped_typeref.h │ ├── md5.cc │ ├── md5.h │ ├── memory │ │ ├── free_deleter.h │ │ ├── ptr_util.h │ │ ├── raw_scoped_refptr_mismatch_checker.h │ │ ├── ref_counted.cc │ │ ├── ref_counted.h │ │ ├── scoped_policy.h │ │ ├── scoped_refptr.h │ │ ├── weak_ptr.cc │ │ └── weak_ptr.h │ ├── numerics │ │ ├── checked_math.h │ │ ├── checked_math_impl.h │ │ ├── clamped_math.h │ │ ├── clamped_math_impl.h │ │ ├── math_constants.h │ │ ├── ranges.h │ │ ├── safe_conversions.h │ │ ├── safe_conversions_impl.h │ │ ├── safe_math.h │ │ ├── safe_math_clang_gcc_impl.h │ │ └── safe_math_shared_impl.h │ ├── posix │ │ ├── eintr_wrapper.h │ │ ├── file_descriptor_shuffle.cc │ │ ├── file_descriptor_shuffle.h │ │ ├── safe_strerror.cc │ │ └── safe_strerror.h │ ├── scoped_clear_errno.h │ ├── scoped_generic.h │ ├── sha1.cc │ ├── sha1.h │ ├── stl_util.h │ ├── strings │ │ ├── string_number_conversions.cc │ │ ├── string_number_conversions.h │ │ ├── string_split.cc │ │ ├── string_split.h │ │ ├── string_tokenizer.h │ │ ├── string_util.cc │ │ ├── string_util.h │ │ ├── string_util_constants.cc │ │ ├── string_util_posix.h │ │ ├── string_util_win.h │ │ ├── stringize_macros.h │ │ ├── stringprintf.cc │ │ ├── stringprintf.h │ │ ├── utf_offset_string_conversions.cc │ │ ├── utf_offset_string_conversions.h │ │ ├── utf_string_conversion_utils.cc │ │ ├── utf_string_conversion_utils.h │ │ ├── utf_string_conversions.cc │ │ └── utf_string_conversions.h │ ├── sys_byteorder.h │ ├── template_util.h │ ├── third_party │ │ └── icu │ │ │ ├── LICENSE │ │ │ ├── README.chromium │ │ │ ├── icu_utf.cc │ │ │ └── icu_utf.h │ ├── timer │ │ ├── elapsed_timer.cc │ │ └── elapsed_timer.h │ ├── value_iterators.cc │ ├── value_iterators.h │ ├── values.cc │ ├── values.h │ └── win │ │ ├── registry.cc │ │ ├── registry.h │ │ ├── scoped_handle.cc │ │ ├── scoped_handle.h │ │ ├── scoped_process_information.cc │ │ ├── scoped_process_information.h │ │ └── win_util.h ├── gn │ ├── action_target_generator.cc │ ├── action_target_generator.h │ ├── action_target_generator_unittest.cc │ ├── action_values.cc │ ├── action_values.h │ ├── analyzer.cc │ ├── analyzer.h │ ├── analyzer_unittest.cc │ ├── args.cc │ ├── args.h │ ├── args_unittest.cc │ ├── binary_target_generator.cc │ ├── binary_target_generator.h │ ├── build_settings.cc │ ├── build_settings.h │ ├── builder.cc │ ├── builder.h │ ├── builder_record.cc │ ├── builder_record.h │ ├── builder_record_map.h │ ├── builder_record_map_unittest.cc │ ├── builder_unittest.cc │ ├── bundle_data.cc │ ├── bundle_data.h │ ├── bundle_data_target_generator.cc │ ├── bundle_data_target_generator.h │ ├── bundle_file_rule.cc │ ├── bundle_file_rule.h │ ├── c_include_iterator.cc │ ├── c_include_iterator.h │ ├── c_include_iterator_unittest.cc │ ├── c_substitution_type.cc │ ├── c_substitution_type.h │ ├── c_tool.cc │ ├── c_tool.h │ ├── command_analyze.cc │ ├── command_args.cc │ ├── command_check.cc │ ├── command_clean.cc │ ├── command_clean_stale.cc │ ├── command_desc.cc │ ├── command_format.cc │ ├── command_format.h │ ├── command_format_unittest.cc │ ├── command_gen.cc │ ├── command_help.cc │ ├── command_ls.cc │ ├── command_meta.cc │ ├── command_outputs.cc │ ├── command_path.cc │ ├── command_refs.cc │ ├── commands.cc │ ├── commands.h │ ├── commands_unittest.cc │ ├── compile_commands_writer.cc │ ├── compile_commands_writer.h │ ├── compile_commands_writer_unittest.cc │ ├── config.cc │ ├── config.h │ ├── config_unittest.cc │ ├── config_values.cc │ ├── config_values.h │ ├── config_values_extractors.cc │ ├── config_values_extractors.h │ ├── config_values_extractors_unittest.cc │ ├── config_values_generator.cc │ ├── config_values_generator.h │ ├── copy_target_generator.cc │ ├── copy_target_generator.h │ ├── create_bundle_target_generator.cc │ ├── create_bundle_target_generator.h │ ├── deps_iterator.cc │ ├── deps_iterator.h │ ├── desc_builder.cc │ ├── desc_builder.h │ ├── eclipse_writer.cc │ ├── eclipse_writer.h │ ├── err.cc │ ├── err.h │ ├── escape.cc │ ├── escape.h │ ├── escape_unittest.cc │ ├── exec_process.cc │ ├── exec_process.h │ ├── exec_process_unittest.cc │ ├── file_writer.cc │ ├── file_writer.h │ ├── file_writer_unittest.cc │ ├── filesystem_utils.cc │ ├── filesystem_utils.h │ ├── filesystem_utils_unittest.cc │ ├── format_test_data │ │ ├── 001.gn │ │ ├── 001.golden │ │ ├── 002.gn │ │ ├── 002.golden │ │ ├── 003.gn │ │ ├── 003.golden │ │ ├── 004.gn │ │ ├── 004.golden │ │ ├── 005.gn │ │ ├── 005.golden │ │ ├── 006.gn │ │ ├── 006.golden │ │ ├── 007.gn │ │ ├── 007.golden │ │ ├── 008.gn │ │ ├── 008.golden │ │ ├── 009.gn │ │ ├── 009.golden │ │ ├── 010.gn │ │ ├── 010.golden │ │ ├── 011.gn │ │ ├── 011.golden │ │ ├── 012.gn │ │ ├── 012.golden │ │ ├── 013.gn │ │ ├── 013.golden │ │ ├── 014.gn │ │ ├── 014.golden │ │ ├── 015.gn │ │ ├── 015.golden │ │ ├── 016.gn │ │ ├── 016.golden │ │ ├── 017.gn │ │ ├── 017.golden │ │ ├── 018.gn │ │ ├── 018.golden │ │ ├── 019.gn │ │ ├── 019.golden │ │ ├── 020.gn │ │ ├── 020.golden │ │ ├── 021.gn │ │ ├── 021.golden │ │ ├── 022.gn │ │ ├── 022.golden │ │ ├── 023.gn │ │ ├── 023.golden │ │ ├── 024.gn │ │ ├── 024.golden │ │ ├── 025.gn │ │ ├── 025.golden │ │ ├── 026.gn │ │ ├── 026.golden │ │ ├── 027.gn │ │ ├── 027.golden │ │ ├── 028.gn │ │ ├── 028.golden │ │ ├── 029.gn │ │ ├── 029.golden │ │ ├── 030.gn │ │ ├── 030.golden │ │ ├── 031.gn │ │ ├── 031.golden │ │ ├── 032.gn │ │ ├── 032.golden │ │ ├── 033.gn │ │ ├── 033.golden │ │ ├── 034.gn │ │ ├── 035.gn │ │ ├── 035.golden │ │ ├── 036.gn │ │ ├── 036.golden │ │ ├── 037.gn │ │ ├── 037.golden │ │ ├── 038.gn │ │ ├── 038.golden │ │ ├── 039.gn │ │ ├── 039.golden │ │ ├── 040.gn │ │ ├── 040.golden │ │ ├── 041.gn │ │ ├── 041.golden │ │ ├── 042.gn │ │ ├── 042.golden │ │ ├── 043.gn │ │ ├── 043.golden │ │ ├── 044.gn │ │ ├── 044.golden │ │ ├── 045.gn │ │ ├── 045.golden │ │ ├── 046.gn │ │ ├── 046.golden │ │ ├── 047.gn │ │ ├── 047.golden │ │ ├── 048.gn │ │ ├── 048.golden │ │ ├── 049.gn │ │ ├── 050.gn │ │ ├── 050.golden │ │ ├── 051.gn │ │ ├── 051.golden │ │ ├── 052.gn │ │ ├── 052.golden │ │ ├── 053.gn │ │ ├── 053.golden │ │ ├── 054.gn │ │ ├── 054.golden │ │ ├── 055.gn │ │ ├── 055.golden │ │ ├── 056.gn │ │ ├── 056.golden │ │ ├── 057.gn │ │ ├── 057.golden │ │ ├── 058.gn │ │ ├── 058.golden │ │ ├── 059.gn │ │ ├── 059.golden │ │ ├── 060.gn │ │ ├── 060.golden │ │ ├── 061.gn │ │ ├── 061.golden │ │ ├── 062.gn │ │ ├── 062.golden │ │ ├── 063.gn │ │ ├── 063.golden │ │ ├── 064.gn │ │ ├── 064.golden │ │ ├── 065.gn │ │ ├── 065.golden │ │ ├── 066.gn │ │ ├── 066.golden │ │ ├── 067.gn │ │ ├── 067.golden │ │ ├── 068.gn │ │ ├── 068.golden │ │ ├── 069.gn │ │ ├── 069.golden │ │ ├── 070.gn │ │ ├── 070.golden │ │ ├── 071.gn │ │ ├── 071.golden │ │ ├── 072.gn │ │ ├── 072.golden │ │ ├── 073.gn │ │ ├── 073.golden │ │ ├── 074.gn │ │ ├── 074.golden │ │ ├── 075.gn │ │ ├── 075.golden │ │ ├── 076.gn │ │ ├── 076.golden │ │ ├── 077.gn │ │ ├── 077.golden │ │ ├── 078.gn │ │ ├── 078.golden │ │ ├── 079.gn │ │ ├── 079.golden │ │ ├── 080.gn │ │ ├── 080.golden │ │ ├── 081.gn │ │ ├── 081.golden │ │ ├── 082.gn │ │ ├── 082.golden │ │ ├── 083.gn │ │ └── 083.golden │ ├── frameworks_utils.cc │ ├── frameworks_utils.h │ ├── frameworks_utils_unittest.cc │ ├── function_exec_script.cc │ ├── function_filter.cc │ ├── function_filter_unittest.cc │ ├── function_foreach.cc │ ├── function_foreach_unittest.cc │ ├── function_forward_variables_from.cc │ ├── function_forward_variables_from_unittest.cc │ ├── function_get_label_info.cc │ ├── function_get_label_info_unittest.cc │ ├── function_get_path_info.cc │ ├── function_get_path_info_unittest.cc │ ├── function_get_target_outputs.cc │ ├── function_get_target_outputs_unittest.cc │ ├── function_process_file_template.cc │ ├── function_process_file_template_unittest.cc │ ├── function_read_file.cc │ ├── function_rebase_path.cc │ ├── function_rebase_path_unittest.cc │ ├── function_set_default_toolchain.cc │ ├── function_set_defaults.cc │ ├── function_template.cc │ ├── function_template_unittest.cc │ ├── function_toolchain.cc │ ├── function_toolchain_unittest.cc │ ├── function_write_file.cc │ ├── function_write_file_unittest.cc │ ├── functions.cc │ ├── functions.h │ ├── functions_target.cc │ ├── functions_target_rust_unittest.cc │ ├── functions_target_unittest.cc │ ├── functions_unittest.cc │ ├── general_tool.cc │ ├── general_tool.h │ ├── generated_file_target_generator.cc │ ├── generated_file_target_generator.h │ ├── gn_main.cc │ ├── group_target_generator.cc │ ├── group_target_generator.h │ ├── hash_table_base.h │ ├── hash_table_base_unittest.cc │ ├── header_checker.cc │ ├── header_checker.h │ ├── header_checker_unittest.cc │ ├── import_manager.cc │ ├── import_manager.h │ ├── inherited_libraries.cc │ ├── inherited_libraries.h │ ├── inherited_libraries_unittest.cc │ ├── input_conversion.cc │ ├── input_conversion.h │ ├── input_conversion_unittest.cc │ ├── input_file.cc │ ├── input_file.h │ ├── input_file_manager.cc │ ├── input_file_manager.h │ ├── item.cc │ ├── item.h │ ├── json_project_writer.cc │ ├── json_project_writer.h │ ├── json_project_writer_unittest.cc │ ├── jumbo_file_list_generator.cc │ ├── jumbo_file_list_generator.h │ ├── jumbo_file_list_generator_unittest.cc │ ├── jumbo_writer.cc │ ├── jumbo_writer.h │ ├── jumbo_writer_unittest.cc │ ├── label.cc │ ├── label.h │ ├── label_pattern.cc │ ├── label_pattern.h │ ├── label_pattern_unittest.cc │ ├── label_ptr.h │ ├── label_unittest.cc │ ├── lib_file.cc │ ├── lib_file.h │ ├── loader.cc │ ├── loader.h │ ├── loader_unittest.cc │ ├── location.cc │ ├── location.h │ ├── metadata.cc │ ├── metadata.h │ ├── metadata_unittest.cc │ ├── metadata_walk.cc │ ├── metadata_walk.h │ ├── metadata_walk_unittest.cc │ ├── ninja_action_target_writer.cc │ ├── ninja_action_target_writer.h │ ├── ninja_action_target_writer_unittest.cc │ ├── ninja_binary_target_writer.cc │ ├── ninja_binary_target_writer.h │ ├── ninja_binary_target_writer_unittest.cc │ ├── ninja_build_writer.cc │ ├── ninja_build_writer.h │ ├── ninja_build_writer_unittest.cc │ ├── ninja_bundle_data_target_writer.cc │ ├── ninja_bundle_data_target_writer.h │ ├── ninja_bundle_data_target_writer_unittest.cc │ ├── ninja_c_binary_target_writer.cc │ ├── ninja_c_binary_target_writer.h │ ├── ninja_c_binary_target_writer_unittest.cc │ ├── ninja_copy_target_writer.cc │ ├── ninja_copy_target_writer.h │ ├── ninja_copy_target_writer_unittest.cc │ ├── ninja_create_bundle_target_writer.cc │ ├── ninja_create_bundle_target_writer.h │ ├── ninja_create_bundle_target_writer_unittest.cc │ ├── ninja_generated_file_target_writer.cc │ ├── ninja_generated_file_target_writer.h │ ├── ninja_generated_file_target_writer_unittest.cc │ ├── ninja_group_target_writer.cc │ ├── ninja_group_target_writer.h │ ├── ninja_group_target_writer_unittest.cc │ ├── ninja_rust_binary_target_writer.cc │ ├── ninja_rust_binary_target_writer.h │ ├── ninja_rust_binary_target_writer_unittest.cc │ ├── ninja_target_command_util.cc │ ├── ninja_target_command_util.h │ ├── ninja_target_command_util_unittest.cc │ ├── ninja_target_writer.cc │ ├── ninja_target_writer.h │ ├── ninja_target_writer_unittest.cc │ ├── ninja_toolchain_writer.cc │ ├── ninja_toolchain_writer.h │ ├── ninja_toolchain_writer_unittest.cc │ ├── ninja_tools.cc │ ├── ninja_tools.h │ ├── ninja_utils.cc │ ├── ninja_utils.h │ ├── ninja_writer.cc │ ├── ninja_writer.h │ ├── operators.cc │ ├── operators.h │ ├── operators_unittest.cc │ ├── output_conversion.cc │ ├── output_conversion.h │ ├── output_conversion_unittest.cc │ ├── output_file.cc │ ├── output_file.h │ ├── parse_node_value_adapter.cc │ ├── parse_node_value_adapter.h │ ├── parse_tree.cc │ ├── parse_tree.h │ ├── parse_tree_unittest.cc │ ├── parser.cc │ ├── parser.h │ ├── parser_unittest.cc │ ├── path_output.cc │ ├── path_output.h │ ├── path_output_unittest.cc │ ├── pattern.cc │ ├── pattern.h │ ├── pattern_unittest.cc │ ├── pointer_set.h │ ├── pointer_set_unittest.cc │ ├── pool.cc │ ├── pool.h │ ├── qt_creator_writer.cc │ ├── qt_creator_writer.h │ ├── runtime_deps.cc │ ├── runtime_deps.h │ ├── runtime_deps_unittest.cc │ ├── rust_project_writer.cc │ ├── rust_project_writer.h │ ├── rust_project_writer_helpers.h │ ├── rust_project_writer_helpers_unittest.cc │ ├── rust_project_writer_unittest.cc │ ├── rust_substitution_type.cc │ ├── rust_substitution_type.h │ ├── rust_tool.cc │ ├── rust_tool.h │ ├── rust_values.cc │ ├── rust_values.h │ ├── rust_values_generator.cc │ ├── rust_values_generator.h │ ├── rust_variables.cc │ ├── rust_variables.h │ ├── scheduler.cc │ ├── scheduler.h │ ├── scope.cc │ ├── scope.h │ ├── scope_per_file_provider.cc │ ├── scope_per_file_provider.h │ ├── scope_per_file_provider_unittest.cc │ ├── scope_unittest.cc │ ├── settings.cc │ ├── settings.h │ ├── setup.cc │ ├── setup.h │ ├── setup_unittest.cc │ ├── source_dir.cc │ ├── source_dir.h │ ├── source_dir_unittest.cc │ ├── source_file.cc │ ├── source_file.h │ ├── source_file_unittest.cc │ ├── standard_out.cc │ ├── standard_out.h │ ├── string_atom.cc │ ├── string_atom.h │ ├── string_atom_unittest.cc │ ├── string_output_buffer.cc │ ├── string_output_buffer.h │ ├── string_output_buffer_unittest.cc │ ├── string_utils.cc │ ├── string_utils.h │ ├── string_utils_unittest.cc │ ├── substitution_list.cc │ ├── substitution_list.h │ ├── substitution_pattern.cc │ ├── substitution_pattern.h │ ├── substitution_pattern_unittest.cc │ ├── substitution_type.cc │ ├── substitution_type.h │ ├── substitution_writer.cc │ ├── substitution_writer.h │ ├── substitution_writer_unittest.cc │ ├── swift_values.cc │ ├── swift_values.h │ ├── swift_values_generator.cc │ ├── swift_values_generator.h │ ├── swift_variables.cc │ ├── swift_variables.h │ ├── switches.cc │ ├── switches.h │ ├── target.cc │ ├── target.h │ ├── target_generator.cc │ ├── target_generator.h │ ├── target_unittest.cc │ ├── template.cc │ ├── template.h │ ├── template_unittest.cc │ ├── test_with_scheduler.cc │ ├── test_with_scheduler.h │ ├── test_with_scope.cc │ ├── test_with_scope.h │ ├── token.cc │ ├── token.h │ ├── tokenizer.cc │ ├── tokenizer.h │ ├── tokenizer_unittest.cc │ ├── tool.cc │ ├── tool.h │ ├── toolchain.cc │ ├── toolchain.h │ ├── trace.cc │ ├── trace.h │ ├── unique_vector.h │ ├── unique_vector_unittest.cc │ ├── value.cc │ ├── value.h │ ├── value_extractors.cc │ ├── value_extractors.h │ ├── value_unittest.cc │ ├── variables.cc │ ├── variables.h │ ├── vector_utils.h │ ├── vector_utils_unittest.cc │ ├── version.cc │ ├── version.h │ ├── version_unittest.cc │ ├── visibility.cc │ ├── visibility.h │ ├── visibility_unittest.cc │ ├── visual_studio_utils.cc │ ├── visual_studio_utils.h │ ├── visual_studio_utils_unittest.cc │ ├── visual_studio_writer.cc │ ├── visual_studio_writer.h │ ├── visual_studio_writer_unittest.cc │ ├── xcode_object.cc │ ├── xcode_object.h │ ├── xcode_object_unittest.cc │ ├── xcode_writer.cc │ ├── xcode_writer.h │ ├── xml_element_writer.cc │ ├── xml_element_writer.h │ └── xml_element_writer_unittest.cc └── util │ ├── auto_reset_event.h │ ├── build_config.h │ ├── exe_path.cc │ ├── exe_path.h │ ├── msg_loop.cc │ ├── msg_loop.h │ ├── semaphore.cc │ ├── semaphore.h │ ├── sys_info.cc │ ├── sys_info.h │ ├── test │ ├── gn_test.cc │ └── test.h │ ├── ticks.cc │ ├── ticks.h │ ├── worker_pool.cc │ └── worker_pool.h └── tools └── find_unreachable.py /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Chromium 2 | Standard: Cpp11 3 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.py] 2 | indent_style = space 3 | indent_size = 2 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.bak 2 | *.gypcmd 3 | *.mk 4 | *.ncb 5 | *.opensdf 6 | *.orig 7 | *.pdb 8 | *.props 9 | *.pyc 10 | *.pyproj 11 | *.rules 12 | *.sdf 13 | *.sln 14 | *.sublime-project 15 | *.sublime-workspace 16 | *.suo 17 | *.targets 18 | *.user 19 | *.vc.opendb 20 | *.vcproj 21 | *.vcxproj 22 | *.vcxproj.filters 23 | *.vpj 24 | *.vpw 25 | *.vpwhistu 26 | *.vtg 27 | *.xcodeproj 28 | *.xcworkspace 29 | *.VC.db 30 | *_proto.xml 31 | *_proto_cpp.xml 32 | *~ 33 | !Android.mk 34 | .*.sw? 35 | .DS_Store 36 | .cipd 37 | .classpath 38 | .cproject 39 | .gdb_history 40 | .gdbinit 41 | .landmines 42 | .metadata 43 | .project 44 | .pydevproject 45 | .recipe_deps 46 | .checkstyle 47 | cscope.* 48 | out/ 49 | GPATH 50 | GRTAGS 51 | GSYMS 52 | GTAGS 53 | Session.vim 54 | tags 55 | Thumbs.db 56 | # Settings directories for eclipse 57 | /.externalToolBuilders/ 58 | /.settings/ 59 | /.vs/ 60 | # Visual Studio Code 61 | /.vscode/ 62 | /_out 63 | -------------------------------------------------------------------------------- /.style.yapf: -------------------------------------------------------------------------------- 1 | [style] 2 | based_on_style = chromium 3 | -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | brettw@chromium.org 2 | phosek@chromium.org 3 | scottmg@chromium.org 4 | -------------------------------------------------------------------------------- /build/build_aix.ninja.template: -------------------------------------------------------------------------------- 1 | rule cxx 2 | command = $cxx -MMD -MF $out.d $includes $cflags -c $in -o $out 3 | description = CXX $out 4 | depfile = $out.d 5 | deps = gcc 6 | 7 | rule alink_thin 8 | command = rm -f $out && $ar rcsT $out $in 9 | description = AR $out 10 | 11 | rule link 12 | command = $ld $ldflags -o $out $in $libs $solibs 13 | description = LINK $out 14 | -------------------------------------------------------------------------------- /build/build_haiku.ninja.template: -------------------------------------------------------------------------------- 1 | rule cxx 2 | command = $cxx -MMD -MF $out.d $includes $cflags -c $in -o $out 3 | description = CXX $out 4 | depfile = $out.d 5 | deps = gcc 6 | 7 | rule alink_thin 8 | command = rm -f $out && $ar rcsT $out $in 9 | description = AR $out 10 | 11 | rule link 12 | command = $ld $ldflags -o $out -Wl,--start-group $in $libs -Wl,--end-group $solibs 13 | description = LINK $out 14 | -------------------------------------------------------------------------------- /build/build_linux.ninja.template: -------------------------------------------------------------------------------- 1 | rule cxx 2 | command = $cxx -MMD -MF $out.d $includes $cflags -c $in -o $out 3 | description = CXX $out 4 | depfile = $out.d 5 | deps = gcc 6 | 7 | rule alink_thin 8 | command = rm -f $out && $ar rcsT $out $in 9 | description = AR $out 10 | 11 | rule link 12 | command = $ld $ldflags -o $out -Wl,--start-group $in $libs -Wl,--end-group $solibs 13 | description = LINK $out 14 | -------------------------------------------------------------------------------- /build/build_mac.ninja.template: -------------------------------------------------------------------------------- 1 | rule cxx 2 | command = $cxx -MMD -MF $out.d $includes $cflags -c $in -o $out 3 | description = CXX $out 4 | depfile = $out.d 5 | deps = gcc 6 | 7 | rule alink_thin 8 | command = rm -f $out && $ar rcs $out $in 9 | description = AR $out 10 | 11 | rule link 12 | command = $ld $ldflags -o $out $in $solibs $libs 13 | description = LINK $out 14 | -------------------------------------------------------------------------------- /build/build_openbsd.ninja.template: -------------------------------------------------------------------------------- 1 | rule cxx 2 | command = $cxx -MMD -MF $out.d $includes $cflags -c $in -o $out 3 | description = CXX $out 4 | depfile = $out.d 5 | deps = gcc 6 | 7 | rule alink_thin 8 | command = rm -f $out && $ar rcs $out $in 9 | description = AR $out 10 | 11 | rule link 12 | command = $ld $ldflags -o $out -Wl,--start-group $in $libs -Wl,--end-group $solibs 13 | description = LINK $out 14 | -------------------------------------------------------------------------------- /build/build_win.ninja.template: -------------------------------------------------------------------------------- 1 | rule cxx 2 | command = ninja -t msvc -- $cxx /nologo /showIncludes /FC $includes $cflags /c $in /Fo$out 3 | description = CXX $out 4 | deps = msvc 5 | 6 | rule alink_thin 7 | command = ninja -t msvc -- $ar /nologo /ignore:4221 $libflags /OUT:$out $in 8 | description = LIB $out 9 | 10 | rule link 11 | command = ninja -t msvc -- $ld /nologo $ldflags /OUT:$out /PDB:$out.pdb $in $solibs $libs 12 | description = LINK $out 13 | -------------------------------------------------------------------------------- /build/build_zos.ninja.template: -------------------------------------------------------------------------------- 1 | rule cxx 2 | command = $cxx $includes $cflags -c $in -o $out 3 | description = CXX $out 4 | depfile = $out.d 5 | deps = gcc 6 | 7 | rule alink_thin 8 | command = rm -f $out && $ar rcsT $out $in 9 | description = AR $out 10 | 11 | rule link 12 | command = $ld $ldflags -o $out $in $libs $solibs 13 | description = LINK $out 14 | -------------------------------------------------------------------------------- /examples/ios/.gitignore: -------------------------------------------------------------------------------- 1 | /out/ 2 | -------------------------------------------------------------------------------- /examples/ios/.gn: -------------------------------------------------------------------------------- 1 | # The location of the build configuration file. 2 | buildconfig = "//build/BUILDCONFIG.gn" 3 | -------------------------------------------------------------------------------- /examples/ios/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | group("all") { 6 | deps = [ 7 | "//app:hello", 8 | "//host:username", 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /examples/ios/app/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #import 6 | 7 | @interface AppDelegate : UIResponder 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /examples/ios/app/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #import "app/AppDelegate.h" 6 | 7 | #import "app/Foo.h" 8 | 9 | @implementation AppDelegate 10 | 11 | - (BOOL)application:(UIApplication*)application 12 | didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { 13 | NSLog(@"%@", [[[FooWrapper alloc] init] helloWithName:@"World"]); 14 | return YES; 15 | } 16 | 17 | #pragma mark - UISceneSession lifecycle 18 | 19 | - (UISceneConfiguration*)application:(UIApplication*)application 20 | configurationForConnectingSceneSession: 21 | (UISceneSession*)connectingSceneSession 22 | options:(UISceneConnectionOptions*)options { 23 | return 24 | [[UISceneConfiguration alloc] initWithName:@"Default Configuration" 25 | sessionRole:connectingSceneSession.role]; 26 | } 27 | 28 | - (void)application:(UIApplication*)application 29 | didDiscardSceneSessions:(NSSet*)sceneSessions { 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /examples/ios/app/Bar.swift: -------------------------------------------------------------------------------- 1 | 2 | import Baz; 3 | 4 | public class Greeter { 5 | public static func greet(greeting: String, name: String, from: String) -> String { 6 | return greeting + ", " + name + " (from " + from + ")"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/ios/app/Baz.swift: -------------------------------------------------------------------------------- 1 | 2 | class Baz {} 3 | -------------------------------------------------------------------------------- /examples/ios/app/Foo-Bridging-Header.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/operasoftware/gn-opera/83647116689f180a61f163cc0275c514bb7b9fe5/examples/ios/app/Foo-Bridging-Header.h -------------------------------------------------------------------------------- /examples/ios/app/Foo.swift: -------------------------------------------------------------------------------- 1 | 2 | import Bar 3 | 4 | class Foo { 5 | var name: String; 6 | public init(name: String) { 7 | self.name = name; 8 | } 9 | public func hello(name: String) -> String { 10 | return Greeter.greet(greeting: "Hello", name: name, from: self.name); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/ios/app/FooWrapper.swift: -------------------------------------------------------------------------------- 1 | 2 | import Foundation; 3 | 4 | @objc 5 | public class FooWrapper : NSObject { 6 | @objc 7 | public func hello(name: String) -> String { 8 | return Foo(name: "Foo").hello(name: name); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/ios/app/SceneDelegate.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #import 6 | 7 | @interface SceneDelegate : UIResponder 8 | 9 | @property(strong, nonatomic) UIWindow* window; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /examples/ios/app/SceneDelegate.m: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #import "app/SceneDelegate.h" 6 | 7 | @implementation SceneDelegate 8 | 9 | - (void)scene:(UIScene*)scene 10 | willConnectToSession:(UISceneSession*)session 11 | options:(UISceneConnectionOptions*)connectionOptions { 12 | } 13 | 14 | - (void)sceneDidDisconnect:(UIScene*)scene { 15 | } 16 | 17 | - (void)sceneDidBecomeActive:(UIScene*)scene { 18 | } 19 | 20 | - (void)sceneWillResignActive:(UIScene*)scene { 21 | } 22 | 23 | - (void)sceneWillEnterForeground:(UIScene*)scene { 24 | } 25 | 26 | - (void)sceneDidEnterBackground:(UIScene*)scene { 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /examples/ios/app/ViewController.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #import 6 | 7 | @interface ViewController : UIViewController 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /examples/ios/app/ViewController.m: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #import 6 | 7 | #import "app/ViewController.h" 8 | 9 | @implementation ViewController 10 | 11 | - (void)viewDidLoad { 12 | [super viewDidLoad]; 13 | 14 | UILabel* label = [self labelWithText:[Greetings greet]]; 15 | [self addCenteredView:label toParentView:self.view]; 16 | } 17 | 18 | - (UILabel*)labelWithText:(NSString*)text { 19 | UILabel* label = [[UILabel alloc] initWithFrame:CGRectZero]; 20 | label.text = text; 21 | [label sizeToFit]; 22 | return label; 23 | } 24 | 25 | - (void)addCenteredView:(UIView*)view toParentView:(UIView*)parentView { 26 | view.center = [parentView convertPoint:parentView.center 27 | fromView:parentView.superview]; 28 | [parentView addSubview:view]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /examples/ios/app/main.m: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #import 6 | #import "app/AppDelegate.h" 7 | 8 | int main(int argc, char** argv) { 9 | NSString* appDelegateClassName; 10 | @autoreleasepool { 11 | appDelegateClassName = NSStringFromClass([AppDelegate class]); 12 | } 13 | 14 | return UIApplicationMain(argc, argv, nil, appDelegateClassName); 15 | } 16 | -------------------------------------------------------------------------------- /examples/ios/build/BUILDCONFIG.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | if (target_os == "") { 6 | target_os = "ios" 7 | } 8 | if (target_cpu == "") { 9 | target_cpu = host_cpu 10 | } 11 | if (current_cpu == "") { 12 | current_cpu = target_cpu 13 | } 14 | if (current_os == "") { 15 | current_os = target_os 16 | } 17 | 18 | # All binary targets will get this list of configs by default. 19 | _shared_binary_target_configs = [ "//build:compiler" ] 20 | 21 | # Apply that default list to the binary target types. 22 | set_defaults("executable") { 23 | configs = _shared_binary_target_configs 24 | configs += [ "//build:shared_binary" ] 25 | } 26 | set_defaults("static_library") { 27 | configs = _shared_binary_target_configs 28 | } 29 | set_defaults("shared_library") { 30 | configs = _shared_binary_target_configs 31 | configs += [ "//build:shared_binary" ] 32 | } 33 | set_defaults("source_set") { 34 | configs = _shared_binary_target_configs 35 | } 36 | 37 | set_default_toolchain("//build/toolchain/$target_os:clang_$target_cpu") 38 | 39 | if (target_os == "ios") { 40 | host_toolchain = "//build/toolchain/$host_os:clang_$host_cpu" 41 | } else { 42 | host_toolchain = default_toolchain 43 | } 44 | -------------------------------------------------------------------------------- /examples/ios/build/config/ios/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/config/ios/sdk_info.gni") 6 | import("//build/config/ios/templates/merge_plist.gni") 7 | 8 | merge_plist("compiler_plist") { 9 | substitutions = { 10 | COMPILER_NAME = sdk_info.compiler 11 | MACOS_BUILD = sdk_info.macos_build 12 | PLATFORM_BUILD = sdk_info.sdk_build 13 | PLATFORM_DISPLAY_NAME = sdk_info.platform_name 14 | PLATFORM_NAME = sdk_info.platform 15 | PLATFORM_VERSION = sdk_info.sdk_version 16 | SDK_BUILD = sdk_info.sdk_build 17 | SDK_NAME = sdk_info.sdk 18 | XCODE_BUILD = sdk_info.xcode_build 19 | XCODE_VERSION = sdk_info.xcode_version 20 | } 21 | 22 | output = "$target_out_dir/compiler_plist/Info.plist" 23 | plists = [ "//build/config/ios/resources/compiler-Info.plist" ] 24 | } 25 | -------------------------------------------------------------------------------- /examples/ios/build/config/ios/bundle_identifier_prefix.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | declare_args() { 6 | # Default bundle identifier prefix. 7 | default_bundle_identifier_prefix = "com.google" 8 | } 9 | -------------------------------------------------------------------------------- /examples/ios/build/config/ios/deployment_target.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | declare_args() { 6 | # Maximum deployment target. Automatically detected by sdk_info.py but 7 | # needs to be specified to a version < 11.0 if targetting 32-bit archs. 8 | ios_deployment_target = "13.0" 9 | } 10 | -------------------------------------------------------------------------------- /examples/ios/build/config/ios/resources/Entitlements-Simulated.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | application-identifier 6 | $(AppIdentifierPrefix)$(CFBundleIdentifier) 7 | keychain-access-groups 8 | 9 | $(AppIdentifierPrefix)$(CFBundleIdentifier) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/ios/build/config/ios/resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | 22 | 23 | -------------------------------------------------------------------------------- /examples/ios/build/config/ios/resources/compiler-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | DTSDKName 6 | $(SDK_NAME) 7 | DTXcode 8 | $(XCODE_VERSION) 9 | DTSDKBuild 10 | $(SDK_BUILD) 11 | BuildMachineOSBuild 12 | $(MACOS_BUILD) 13 | DTPlatformName 14 | $(PLATFORM_NAME) 15 | DTCompiler 16 | $(COMPILER_NAME) 17 | DTPlatformVersion 18 | $(PLATFORM_VERSION) 19 | DTXcodeBuild 20 | $(XCODE_BUILD) 21 | DTPlatformBuild 22 | $(PLATFORM_BUILD) 23 | CFBundleSupportedPlatforms 24 | 25 | $(PLATFORM_DISPLAY_NAME) 26 | 27 | UIDeviceFamily 28 | 29 | 1 30 | 2 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /examples/ios/build/config/ios/sdk_info.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/config/ios/deployment_target.gni") 6 | 7 | sdk_info = exec_script("//build/config/ios/scripts/sdk_info.py", 8 | [ 9 | "--target-cpu", 10 | current_cpu, 11 | "--deployment-target", 12 | ios_deployment_target, 13 | ], 14 | "json") 15 | -------------------------------------------------------------------------------- /examples/ios/build/config/ios/templates/storyboards.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/config/ios/deployment_target.gni") 6 | 7 | template("storyboards") { 8 | assert(defined(invoker.sources), 9 | "sources must be defined for storyboard ($target_name)") 10 | 11 | _compile_target = target_name + "_compile" 12 | _compile_output = 13 | "$target_out_dir/$_compile_target/{{source_name_part}}.storyboardc" 14 | 15 | action_foreach(_compile_target) { 16 | script = "//build/config/ios/scripts/compile_storyboard.py" 17 | sources = invoker.sources 18 | outputs = [ _compile_output ] 19 | args = [ 20 | "{{source}}", 21 | "-o=" + rebase_path(_compile_output, root_build_dir), 22 | "--minimum-deployment-target=$ios_deployment_target", 23 | ] 24 | } 25 | 26 | bundle_data(target_name) { 27 | public_deps = [ ":$_compile_target" ] 28 | sources = get_target_outputs(":$_compile_target") 29 | outputs = [ "{{bundle_root_dir}}/Base.lproj/{{source_file_part}}" ] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/ios/host/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | if (current_toolchain == host_toolchain) { 6 | executable("username") { 7 | sources = [ "main.cc" ] 8 | } 9 | } else { 10 | group("username") { 11 | deps = [ ":username($host_toolchain)" ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/ios/shared/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("//build/config/ios/templates/ios_framework_bundle.gni") 6 | 7 | ios_framework_bundle("hello_framework") { 8 | output_name = "HelloShared" 9 | 10 | sources = [ 11 | "hello_shared.h", 12 | "hello_shared.m", 13 | ] 14 | public_headers = [ "hello_shared.h" ] 15 | 16 | defines = [ "HELLO_SHARED_IMPLEMENTATION" ] 17 | frameworks = [ "Foundation.framework" ] 18 | } 19 | -------------------------------------------------------------------------------- /examples/ios/shared/hello_shared.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #import 6 | 7 | @interface Greetings : NSObject 8 | 9 | + (NSString*)greet; 10 | 11 | + (NSString*)greetWithName:(NSString*)name; 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /examples/ios/shared/hello_shared.m: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #import "hello_shared.h" 6 | 7 | @implementation Greetings 8 | 9 | + (NSString*)greet { 10 | return [NSString stringWithFormat:@"Hello from %@!", [Greetings displayName]]; 11 | } 12 | 13 | + (NSString*)greetWithName:(NSString*)name { 14 | return [NSString stringWithFormat:@"Hello, %@!", name]; 15 | } 16 | 17 | + (NSString*)displayName { 18 | NSBundle* bundle = [NSBundle bundleForClass:[Greetings class]]; 19 | return [[bundle infoDictionary] objectForKey:@"CFBundleName"]; 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /examples/rust_example/.gn: -------------------------------------------------------------------------------- 1 | buildconfig = "//BUILDCONFIG.gn" 2 | -------------------------------------------------------------------------------- /examples/rust_example/BUILD.gn: -------------------------------------------------------------------------------- 1 | group("default") { 2 | deps = [ "//hello_world/src:hello_world" ] 3 | } 4 | -------------------------------------------------------------------------------- /examples/rust_example/BUILDCONFIG.gn: -------------------------------------------------------------------------------- 1 | if (target_os == "") { 2 | target_os = host_os 3 | } 4 | if (target_cpu == "") { 5 | target_cpu = host_cpu 6 | } 7 | if (current_cpu == "") { 8 | current_cpu = target_cpu 9 | } 10 | if (current_os == "") { 11 | current_os = target_os 12 | } 13 | 14 | _configs = [ "//build:rust_defaults" ] 15 | 16 | set_defaults("executable") { 17 | configs = _configs 18 | } 19 | set_defaults("rust_library") { 20 | configs = _configs 21 | } 22 | 23 | set_default_toolchain("//build:rust") 24 | -------------------------------------------------------------------------------- /examples/rust_example/README.txt: -------------------------------------------------------------------------------- 1 | This is an example directory structure that compiles a Rust hello world 2 | example. It is intended to show how to set up a simple Rust GN build. 3 | 4 | Don't miss the ".gn" file in this directory! 5 | -------------------------------------------------------------------------------- /examples/rust_example/hello_world/bar/src/BUILD.gn: -------------------------------------------------------------------------------- 1 | rust_library("bar") { 2 | crate_root = "lib.rs" 3 | } 4 | -------------------------------------------------------------------------------- /examples/rust_example/hello_world/bar/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests { 3 | #[test] 4 | fn it_works() { 5 | assert_eq!(2 + 2, 4); 6 | } 7 | } 8 | 9 | #[derive(Debug)] 10 | pub struct Foo { 11 | s: &'static str, 12 | i: &'static str 13 | } 14 | 15 | impl Foo { 16 | pub fn new(s: &'static str) -> Foo { 17 | Foo{s: s, i: "bar"} 18 | } 19 | } 20 | 21 | pub fn answer() -> i32 { 22 | 42 23 | } -------------------------------------------------------------------------------- /examples/rust_example/hello_world/foo/src/BUILD.gn: -------------------------------------------------------------------------------- 1 | rust_library("foo") { 2 | sources = [ "lib.rs" ] 3 | deps = [ "//hello_world/bar/src:bar" ] 4 | } 5 | -------------------------------------------------------------------------------- /examples/rust_example/hello_world/foo/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | pub struct Foo { 3 | s: &'static str, 4 | i: &'static str 5 | } 6 | 7 | impl Foo { 8 | pub fn new(s: &'static str) -> Foo { 9 | Foo{s: s, i: "foo"} 10 | } 11 | } -------------------------------------------------------------------------------- /examples/rust_example/hello_world/src/BUILD.gn: -------------------------------------------------------------------------------- 1 | executable("hello_world") { 2 | sources = [ "main.rs" ] 3 | deps = [ "//hello_world/foo/src:foo" ] 4 | aliased_deps = { 5 | baz = "//hello_world/foo/src:foo" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/rust_example/hello_world/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let f = baz::Foo::new("hello"); 3 | println!("Hello world!"); 4 | println!("I'm from a dependency: {:?}!", f); 5 | } -------------------------------------------------------------------------------- /examples/simple_build/.gn: -------------------------------------------------------------------------------- 1 | # The location of the build configuration file. 2 | buildconfig = "//build/BUILDCONFIG.gn" 3 | -------------------------------------------------------------------------------- /examples/simple_build/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | executable("hello") { 6 | sources = [ "hello.cc" ] 7 | 8 | deps = [ 9 | ":hello_shared", 10 | ":hello_static", 11 | ] 12 | } 13 | 14 | shared_library("hello_shared") { 15 | sources = [ 16 | "hello_shared.cc", 17 | "hello_shared.h", 18 | ] 19 | 20 | defines = [ "HELLO_SHARED_IMPLEMENTATION" ] 21 | } 22 | 23 | static_library("hello_static") { 24 | sources = [ 25 | "hello_static.cc", 26 | "hello_static.h", 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /examples/simple_build/README.md: -------------------------------------------------------------------------------- 1 | # GN Simple Build Example 2 | 3 | This is an example directory structure that compiles some simple targets using 4 | gcc. It is intended to show how to set up a simple GN build. It is deliberately 5 | simplistic so the structure is more clear, and doesn't support everything on 6 | every platform. 7 | 8 | It is recommended that you take this and add on as your requirements indicate. 9 | You may also want to see the Chromium and Fuchsia build configurations for the 10 | maximal functionality (the [root README](../../README.md) has links to these). 11 | 12 | Don't miss the ".gn" file in this directory which may be hidden on your system! 13 | -------------------------------------------------------------------------------- /examples/simple_build/build/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | config("compiler_defaults") { 6 | if (current_os == "linux") { 7 | cflags = [ 8 | "-fPIC", 9 | "-pthread", 10 | ] 11 | } 12 | } 13 | 14 | config("executable_ldconfig") { 15 | if (!is_mac) { 16 | ldflags = [ 17 | "-Wl,-rpath=\$ORIGIN/", 18 | "-Wl,-rpath-link=", 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/simple_build/build/BUILDCONFIG.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | if (target_os == "") { 6 | target_os = host_os 7 | } 8 | if (target_cpu == "") { 9 | target_cpu = host_cpu 10 | } 11 | if (current_cpu == "") { 12 | current_cpu = target_cpu 13 | } 14 | if (current_os == "") { 15 | current_os = target_os 16 | } 17 | 18 | is_linux = host_os == "linux" && current_os == "linux" && target_os == "linux" 19 | is_mac = host_os == "mac" && current_os == "mac" && target_os == "mac" 20 | 21 | # All binary targets will get this list of configs by default. 22 | _shared_binary_target_configs = [ "//build:compiler_defaults" ] 23 | 24 | # Apply that default list to the binary target types. 25 | set_defaults("executable") { 26 | configs = _shared_binary_target_configs 27 | 28 | # Executables get this additional configuration. 29 | configs += [ "//build:executable_ldconfig" ] 30 | } 31 | set_defaults("static_library") { 32 | configs = _shared_binary_target_configs 33 | } 34 | set_defaults("shared_library") { 35 | configs = _shared_binary_target_configs 36 | } 37 | set_defaults("source_set") { 38 | configs = _shared_binary_target_configs 39 | } 40 | 41 | set_default_toolchain("//build/toolchain:gcc") 42 | -------------------------------------------------------------------------------- /examples/simple_build/hello.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include 6 | 7 | #include "hello_shared.h" 8 | #include "hello_static.h" 9 | 10 | int main(int argc, char* argv[]) { 11 | printf("%s, %s\n", GetStaticText(), GetSharedText()); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /examples/simple_build/hello_shared.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "hello_shared.h" 6 | 7 | const char* GetSharedText() { 8 | return "world"; 9 | } 10 | -------------------------------------------------------------------------------- /examples/simple_build/hello_shared.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_EXAMPLE_HELLO_SHARED_H_ 6 | #define TOOLS_GN_EXAMPLE_HELLO_SHARED_H_ 7 | 8 | #if defined(WIN32) 9 | 10 | #if defined(HELLO_SHARED_IMPLEMENTATION) 11 | #define HELLO_EXPORT __declspec(dllexport) 12 | #define HELLO_EXPORT_PRIVATE __declspec(dllexport) 13 | #else 14 | #define HELLO_EXPORT __declspec(dllimport) 15 | #define HELLO_EXPORT_PRIVATE __declspec(dllimport) 16 | #endif // defined(HELLO_SHARED_IMPLEMENTATION) 17 | 18 | #else 19 | 20 | #if defined(HELLO_SHARED_IMPLEMENTATION) 21 | #define HELLO_EXPORT __attribute__((visibility("default"))) 22 | #define HELLO_EXPORT_PRIVATE __attribute__((visibility("default"))) 23 | #else 24 | #define HELLO_EXPORT 25 | #define HELLO_EXPORT_PRIVATE 26 | #endif // defined(HELLO_SHARED_IMPLEMENTATION) 27 | 28 | #endif 29 | 30 | HELLO_EXPORT const char* GetSharedText(); 31 | 32 | #endif // TOOLS_GN_EXAMPLE_HELLO_SHARED_H_ 33 | -------------------------------------------------------------------------------- /examples/simple_build/hello_static.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "hello_static.h" 6 | 7 | const char* GetStaticText() { 8 | return "Hello"; 9 | } 10 | -------------------------------------------------------------------------------- /examples/simple_build/hello_static.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_EXAMPLE_HELLO_STATIC_H_ 6 | #define TOOLS_GN_EXAMPLE_HELLO_STATIC_H_ 7 | 8 | const char* GetStaticText(); 9 | 10 | #endif // TOOLS_GN_EXAMPLE_HELLO_STATIC_H_ 11 | -------------------------------------------------------------------------------- /examples/simple_build/tutorial/README.md: -------------------------------------------------------------------------------- 1 | # Tutorial directory 2 | 3 | This directory isn't used by the simple build example by default. It's here to 4 | be used for the example in the [quick start guide](../../../docs/quick_start.md). 5 | -------------------------------------------------------------------------------- /examples/simple_build/tutorial/tutorial.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include 6 | 7 | int main(int argc, char* argv[]) { 8 | printf("Hello from the tutorial.\n"); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /infra/config/generated/commit-queue.cfg: -------------------------------------------------------------------------------- 1 | # Auto-generated by lucicfg. 2 | # Do not modify manually. 3 | # 4 | # For the schema of this file, see Config message: 5 | # https://luci-config.appspot.com/schemas/projects:commit-queue.cfg 6 | 7 | submit_options { 8 | max_burst: 4 9 | burst_delay { 10 | seconds: 480 11 | } 12 | } 13 | config_groups { 14 | name: "gn" 15 | gerrit { 16 | url: "https://gn-review.googlesource.com" 17 | projects { 18 | name: "gn" 19 | ref_regexp: "refs/heads/main" 20 | } 21 | } 22 | verifiers { 23 | gerrit_cq_ability { 24 | committer_list: "project-gn-committers" 25 | dry_run_access_list: "project-gn-tryjob-access" 26 | } 27 | tryjob { 28 | builders { 29 | name: "gn/try/linux" 30 | } 31 | builders { 32 | name: "gn/try/mac" 33 | } 34 | builders { 35 | name: "gn/try/win" 36 | } 37 | retry_config { 38 | single_quota: 1 39 | global_quota: 2 40 | failure_weight: 1 41 | transient_failure_weight: 1 42 | timeout_weight: 2 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /infra/config/generated/luci-logdog.cfg: -------------------------------------------------------------------------------- 1 | # Auto-generated by lucicfg. 2 | # Do not modify manually. 3 | # 4 | # For the schema of this file, see ProjectConfig message: 5 | # https://luci-config.appspot.com/schemas/projects:luci-logdog.cfg 6 | 7 | reader_auth_groups: "all" 8 | writer_auth_groups: "luci-logdog-chromium-writers" 9 | archive_gs_bucket: "chromium-luci-logdog" 10 | -------------------------------------------------------------------------------- /infra/config/generated/luci-milo.cfg: -------------------------------------------------------------------------------- 1 | # Auto-generated by lucicfg. 2 | # Do not modify manually. 3 | # 4 | # For the schema of this file, see Project message: 5 | # https://luci-config.appspot.com/schemas/projects:luci-milo.cfg 6 | 7 | consoles { 8 | id: "gn" 9 | name: "gn" 10 | repo_url: "https://gn.googlesource.com/gn" 11 | refs: "regexp:refs/heads/main" 12 | manifest_name: "REVISION" 13 | builders { 14 | name: "buildbucket/luci.gn.ci/linux" 15 | short_name: "linux" 16 | } 17 | builders { 18 | name: "buildbucket/luci.gn.ci/mac" 19 | short_name: "mac" 20 | } 21 | builders { 22 | name: "buildbucket/luci.gn.ci/win" 23 | short_name: "win" 24 | } 25 | favicon_url: "https://storage.googleapis.com/chrome-infra-public/logo/favicon.ico" 26 | } 27 | logo_url: "https://storage.googleapis.com/chrome-infra-public/logo/gn-logo.png" 28 | -------------------------------------------------------------------------------- /infra/config/generated/luci-scheduler.cfg: -------------------------------------------------------------------------------- 1 | # Auto-generated by lucicfg. 2 | # Do not modify manually. 3 | # 4 | # For the schema of this file, see ProjectConfig message: 5 | # https://luci-config.appspot.com/schemas/projects:luci-scheduler.cfg 6 | 7 | job { 8 | id: "linux" 9 | realm: "ci" 10 | acl_sets: "ci" 11 | buildbucket { 12 | server: "cr-buildbucket.appspot.com" 13 | bucket: "luci.gn.ci" 14 | builder: "linux" 15 | } 16 | } 17 | job { 18 | id: "mac" 19 | realm: "ci" 20 | acl_sets: "ci" 21 | buildbucket { 22 | server: "cr-buildbucket.appspot.com" 23 | bucket: "luci.gn.ci" 24 | builder: "mac" 25 | } 26 | } 27 | job { 28 | id: "win" 29 | realm: "ci" 30 | acl_sets: "ci" 31 | buildbucket { 32 | server: "cr-buildbucket.appspot.com" 33 | bucket: "luci.gn.ci" 34 | builder: "win" 35 | } 36 | } 37 | trigger { 38 | id: "gn-trigger" 39 | realm: "ci" 40 | acl_sets: "ci" 41 | triggers: "linux" 42 | triggers: "mac" 43 | triggers: "win" 44 | gitiles { 45 | repo: "https://gn.googlesource.com/gn" 46 | refs: "regexp:refs/heads/main" 47 | } 48 | } 49 | acl_sets { 50 | name: "ci" 51 | acls { 52 | role: OWNER 53 | granted_to: "group:project-gn-committers" 54 | } 55 | acls { 56 | granted_to: "group:all" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /infra/config/generated/project.cfg: -------------------------------------------------------------------------------- 1 | # Auto-generated by lucicfg. 2 | # Do not modify manually. 3 | # 4 | # For the schema of this file, see ProjectCfg message: 5 | # https://luci-config.appspot.com/schemas/projects:project.cfg 6 | 7 | name: "gn" 8 | access: "group:all" 9 | -------------------------------------------------------------------------------- /infra/config/generated/realms.cfg: -------------------------------------------------------------------------------- 1 | # Auto-generated by lucicfg. 2 | # Do not modify manually. 3 | # 4 | # For the schema of this file, see RealmsCfg message: 5 | # https://luci-config.appspot.com/schemas/projects:realms.cfg 6 | 7 | realms { 8 | name: "@root" 9 | bindings { 10 | role: "role/buildbucket.reader" 11 | principals: "group:all" 12 | } 13 | bindings { 14 | role: "role/configs.reader" 15 | principals: "group:all" 16 | } 17 | bindings { 18 | role: "role/logdog.reader" 19 | principals: "group:all" 20 | } 21 | bindings { 22 | role: "role/logdog.writer" 23 | principals: "group:luci-logdog-chromium-writers" 24 | } 25 | bindings { 26 | role: "role/scheduler.owner" 27 | principals: "group:project-gn-committers" 28 | } 29 | bindings { 30 | role: "role/scheduler.reader" 31 | principals: "group:all" 32 | } 33 | } 34 | realms { 35 | name: "ci" 36 | bindings { 37 | role: "role/buildbucket.builderServiceAccount" 38 | principals: "user:gn-ci-builder@chops-service-accounts.iam.gserviceaccount.com" 39 | } 40 | } 41 | realms { 42 | name: "try" 43 | bindings { 44 | role: "role/buildbucket.builderServiceAccount" 45 | principals: "user:gn-try-builder@chops-service-accounts.iam.gserviceaccount.com" 46 | } 47 | bindings { 48 | role: "role/buildbucket.triggerer" 49 | principals: "group:project-gn-tryjob-access" 50 | principals: "group:service-account-cq" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /infra/config/recipes.cfg: -------------------------------------------------------------------------------- 1 | { 2 | "api_version": 2, 3 | "deps": { 4 | "recipe_engine": { 5 | "branch": "main", 6 | "revision": "d31ba13ede8c21e60116ae61e4490d53ba77fcbd", 7 | "url": "https://chromium.googlesource.com/infra/luci/recipes-py" 8 | } 9 | }, 10 | "project_id": "gn", 11 | "recipes_path": "infra" 12 | } 13 | -------------------------------------------------------------------------------- /infra/recipe_modules/macos_sdk/examples/full.expected/linux.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "cmd": [ 4 | "gn", 5 | "gen", 6 | "out/Release" 7 | ], 8 | "name": "gn" 9 | }, 10 | { 11 | "cmd": [ 12 | "ninja", 13 | "-C", 14 | "out/Release" 15 | ], 16 | "name": "ninja" 17 | }, 18 | { 19 | "name": "$result" 20 | } 21 | ] -------------------------------------------------------------------------------- /infra/recipe_modules/macos_sdk/examples/full.expected/win.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "cmd": [ 4 | "gn", 5 | "gen", 6 | "out/Release" 7 | ], 8 | "name": "gn" 9 | }, 10 | { 11 | "cmd": [ 12 | "ninja", 13 | "-C", 14 | "out/Release" 15 | ], 16 | "name": "ninja" 17 | }, 18 | { 19 | "name": "$result" 20 | } 21 | ] -------------------------------------------------------------------------------- /infra/recipe_modules/macos_sdk/examples/full.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | DEPS = [ 6 | 'macos_sdk', 7 | 'recipe_engine/platform', 8 | 'recipe_engine/properties', 9 | 'recipe_engine/step', 10 | ] 11 | 12 | 13 | def RunSteps(api): 14 | with api.macos_sdk(): 15 | sdk_dir = api.macos_sdk.sdk_dir if api.platform.is_mac else None 16 | api.step('gn', ['gn', 'gen', 'out/Release']) 17 | api.step('ninja', ['ninja', '-C', 'out/Release']) 18 | 19 | 20 | def GenTests(api): 21 | for platform in ('linux', 'mac', 'win'): 22 | yield (api.test(platform) + api.platform.name(platform) + 23 | api.properties.generic(buildername='test_builder')) 24 | -------------------------------------------------------------------------------- /infra/recipe_modules/target/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | DEPS = [ 6 | 'recipe_engine/platform', 7 | ] 8 | -------------------------------------------------------------------------------- /infra/recipe_modules/target/examples/full.expected/linux.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "cmd": [], 4 | "name": "platform things", 5 | "~followup_annotations": [ 6 | "@@@STEP_LOG_LINE@name@fuchsia@@@", 7 | "@@@STEP_LOG_END@name@@@", 8 | "@@@STEP_LOG_LINE@arch@arm64@@@", 9 | "@@@STEP_LOG_END@arch@@@", 10 | "@@@STEP_LOG_LINE@platform@fuchsia-arm64@@@", 11 | "@@@STEP_LOG_END@platform@@@", 12 | "@@@STEP_LOG_LINE@triple@aarch64-fuchsia@@@", 13 | "@@@STEP_LOG_END@triple@@@", 14 | "@@@STEP_LOG_LINE@string@fuchsia-arm64@@@", 15 | "@@@STEP_LOG_END@string@@@" 16 | ] 17 | }, 18 | { 19 | "name": "$result" 20 | } 21 | ] -------------------------------------------------------------------------------- /infra/recipe_modules/target/examples/full.expected/mac.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "cmd": [], 4 | "name": "platform things", 5 | "~followup_annotations": [ 6 | "@@@STEP_LOG_LINE@name@fuchsia@@@", 7 | "@@@STEP_LOG_END@name@@@", 8 | "@@@STEP_LOG_LINE@arch@arm64@@@", 9 | "@@@STEP_LOG_END@arch@@@", 10 | "@@@STEP_LOG_LINE@platform@fuchsia-arm64@@@", 11 | "@@@STEP_LOG_END@platform@@@", 12 | "@@@STEP_LOG_LINE@triple@aarch64-fuchsia@@@", 13 | "@@@STEP_LOG_END@triple@@@", 14 | "@@@STEP_LOG_LINE@string@fuchsia-arm64@@@", 15 | "@@@STEP_LOG_END@string@@@" 16 | ] 17 | }, 18 | { 19 | "name": "$result" 20 | } 21 | ] -------------------------------------------------------------------------------- /infra/recipe_modules/target/examples/full.expected/win.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "cmd": [], 4 | "name": "platform things", 5 | "~followup_annotations": [ 6 | "@@@STEP_LOG_LINE@name@fuchsia@@@", 7 | "@@@STEP_LOG_END@name@@@", 8 | "@@@STEP_LOG_LINE@arch@arm64@@@", 9 | "@@@STEP_LOG_END@arch@@@", 10 | "@@@STEP_LOG_LINE@platform@fuchsia-arm64@@@", 11 | "@@@STEP_LOG_END@platform@@@", 12 | "@@@STEP_LOG_LINE@triple@aarch64-fuchsia@@@", 13 | "@@@STEP_LOG_END@triple@@@", 14 | "@@@STEP_LOG_LINE@string@fuchsia-arm64@@@", 15 | "@@@STEP_LOG_END@string@@@" 16 | ] 17 | }, 18 | { 19 | "name": "$result" 20 | } 21 | ] -------------------------------------------------------------------------------- /infra/recipe_modules/target/examples/full.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | DEPS = [ 6 | 'target', 7 | 'recipe_engine/platform', 8 | 'recipe_engine/properties', 9 | 'recipe_engine/step', 10 | ] 11 | 12 | 13 | def RunSteps(api): 14 | target = api.target('fuchsia-arm64') 15 | assert not target.is_win 16 | assert not target.is_linux 17 | assert not target.is_mac 18 | assert api.target.host.is_host 19 | assert target != api.target.host 20 | assert target != 'foo' 21 | step_result = api.step('platform things', cmd=None) 22 | step_result.presentation.logs['name'] = [target.os] 23 | step_result.presentation.logs['arch'] = [target.arch] 24 | step_result.presentation.logs['platform'] = [target.platform] 25 | step_result.presentation.logs['triple'] = [target.triple] 26 | step_result.presentation.logs['string'] = [str(target)] 27 | 28 | 29 | def GenTests(api): 30 | for platform in ('linux', 'mac', 'win'): 31 | yield api.test(platform) + api.platform.name(platform) 32 | -------------------------------------------------------------------------------- /infra/recipe_modules/windows_sdk/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | DEPS = [ 6 | 'recipe_engine/cipd', 7 | 'recipe_engine/context', 8 | 'recipe_engine/json', 9 | 'recipe_engine/path', 10 | 'recipe_engine/platform', 11 | 'recipe_engine/step', 12 | ] 13 | 14 | from recipe_engine.recipe_api import Property 15 | from recipe_engine.config import ConfigGroup, Single 16 | 17 | PROPERTIES = { 18 | '$gn/windows_sdk': 19 | Property( 20 | help='Properties specifically for the windows_sdk module.', 21 | param_name='sdk_properties', 22 | kind=ConfigGroup( 23 | # The CIPD package and version. 24 | sdk_package=Single(str), 25 | sdk_version=Single(str)), 26 | default={ 27 | 'sdk_package': 'chrome_internal/third_party/sdk/windows', 28 | 'sdk_version': 'uploaded:2019-09-06' 29 | }, 30 | ) 31 | } 32 | -------------------------------------------------------------------------------- /infra/recipe_modules/windows_sdk/examples/full.expected/linux.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "cmd": [ 4 | "gn", 5 | "gen", 6 | "out/Release" 7 | ], 8 | "name": "gn" 9 | }, 10 | { 11 | "cmd": [ 12 | "ninja", 13 | "-C", 14 | "out/Release" 15 | ], 16 | "name": "ninja" 17 | }, 18 | { 19 | "name": "$result" 20 | } 21 | ] -------------------------------------------------------------------------------- /infra/recipe_modules/windows_sdk/examples/full.expected/mac.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "cmd": [ 4 | "gn", 5 | "gen", 6 | "out/Release" 7 | ], 8 | "name": "gn" 9 | }, 10 | { 11 | "cmd": [ 12 | "ninja", 13 | "-C", 14 | "out/Release" 15 | ], 16 | "name": "ninja" 17 | }, 18 | { 19 | "name": "$result" 20 | } 21 | ] -------------------------------------------------------------------------------- /infra/recipe_modules/windows_sdk/examples/full.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | DEPS = [ 6 | 'windows_sdk', 7 | 'recipe_engine/platform', 8 | 'recipe_engine/properties', 9 | 'recipe_engine/step', 10 | ] 11 | 12 | 13 | def RunSteps(api): 14 | with api.windows_sdk(): 15 | api.step('gn', ['gn', 'gen', 'out/Release']) 16 | api.step('ninja', ['ninja', '-C', 'out/Release']) 17 | 18 | 19 | def GenTests(api): 20 | for platform in ('linux', 'mac', 'win'): 21 | properties = { 22 | 'buildername': 'test_builder', 23 | } 24 | yield (api.test(platform) + api.platform.name(platform) + 25 | api.properties.generic(**properties)) 26 | -------------------------------------------------------------------------------- /misc/emacs/.gitignore: -------------------------------------------------------------------------------- 1 | *.elc 2 | -------------------------------------------------------------------------------- /misc/tm/GN.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Comments 7 | scope 8 | source.gn 9 | settings 10 | 11 | shellVariables 12 | 13 | 14 | name 15 | TM_COMMENT_START 16 | value 17 | # 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /misc/vim/autoload/gn.vim: -------------------------------------------------------------------------------- 1 | " Copyright 2017 The Chromium Authors. All rights reserved. 2 | " Use of this source code is governed by a BSD-style license that can be 3 | " found in the LICENSE file. 4 | 5 | function! gn#TranslateToBuildFile(name) abort 6 | " Strip '//' prefix 7 | let l:new_path = substitute(a:name, '\v^//', '', '') 8 | 9 | " Strip the build target name (necessary if 'isfname' contains ':') 10 | let l:new_path = substitute(l:new_path, '\v:.*$', '', '') 11 | 12 | " Append 'BUILD.gn', only if this is a directory and not a file 13 | " Prefer using maktaba if it's available, but fallback to an alternative 14 | if exists('*maktaba#path#Basename') 15 | " Check if the last part of the path appears to be a file 16 | if maktaba#path#Basename(l:new_path) !~# '\V.' 17 | let l:new_path = maktaba#path#Join([l:new_path, 'BUILD.gn']) 18 | endif 19 | else 20 | " This will break if 'autochdir' is enabled 21 | if isdirectory(l:new_path) 22 | let l:new_path = substitute(l:new_path, '\v/?$', '/BUILD.gn', '') 23 | endif 24 | endif 25 | return l:new_path 26 | endfunction 27 | -------------------------------------------------------------------------------- /misc/vim/ftdetect/gnfiletype.vim: -------------------------------------------------------------------------------- 1 | " Copyright 2014 The Chromium Authors. All rights reserved. 2 | " Use of this source code is governed by a BSD-style license that can be 3 | " found in the LICENSE file. 4 | 5 | " We take care to preserve the user's fileencodings and fileformats, 6 | " because those settings are global (not buffer local), yet we want 7 | " to override them for loading GN files, which should be UTF-8. 8 | let s:current_fileformats = '' 9 | let s:current_fileencodings = '' 10 | 11 | " define fileencodings to open as utf-8 encoding even if it's ascii. 12 | function! s:gnfiletype_pre() 13 | let s:current_fileformats = &g:fileformats 14 | let s:current_fileencodings = &g:fileencodings 15 | set fileencodings=utf-8 fileformats=unix 16 | setlocal filetype=gn 17 | endfunction 18 | 19 | " restore fileencodings as others 20 | function! s:gnfiletype_post() 21 | let &g:fileformats = s:current_fileformats 22 | let &g:fileencodings = s:current_fileencodings 23 | endfunction 24 | 25 | au BufNewFile *.gn,*.gni setlocal filetype=gn fileencoding=utf-8 fileformat=unix 26 | au BufRead *.gn,*.gni call s:gnfiletype_pre() 27 | au BufReadPost *.gn,*.gni call s:gnfiletype_post() 28 | -------------------------------------------------------------------------------- /misc/vim/ftplugin/gn.vim: -------------------------------------------------------------------------------- 1 | " Copyright 2017 The Chromium Authors. All rights reserved. 2 | " Use of this source code is governed by a BSD-style license that can be 3 | " found in the LICENSE file. 4 | 5 | if exists('b:did_ftplugin') 6 | finish 7 | endif 8 | let b:did_ftplugin = 1 9 | 10 | setlocal includeexpr=gn#TranslateToBuildFile(v:fname) 11 | 12 | setlocal commentstring=#\ %s 13 | -------------------------------------------------------------------------------- /src/base/containers/queue.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_CONTAINERS_QUEUE_H_ 6 | #define BASE_CONTAINERS_QUEUE_H_ 7 | 8 | #include 9 | 10 | #include "base/containers/circular_deque.h" 11 | 12 | namespace base { 13 | 14 | // Provides a definition of base::queue that's like std::queue but uses a 15 | // base::circular_queue instead of std::deque. Since std::queue is just a 16 | // wrapper for an underlying type, we can just provide a typedef for it that 17 | // defaults to the base circular_deque. 18 | template > 19 | using queue = std::queue; 20 | 21 | } // namespace base 22 | 23 | #endif // BASE_CONTAINERS_QUEUE_H_ 24 | -------------------------------------------------------------------------------- /src/base/containers/stack.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_CONTAINERS_STACK_H_ 6 | #define BASE_CONTAINERS_STACK_H_ 7 | 8 | #include 9 | 10 | #include "base/containers/circular_deque.h" 11 | 12 | namespace base { 13 | 14 | // Provides a definition of base::stack that's like std::stack but uses a 15 | // base::circular_queue instead of std::deque. Since std::stack is just a 16 | // wrapper for an underlying type, we can just provide a typedef for it that 17 | // defaults to the base circular_deque. 18 | template > 19 | using stack = std::stack; 20 | 21 | } // namespace base 22 | 23 | #endif // BASE_CONTAINERS_STACK_H_ 24 | -------------------------------------------------------------------------------- /src/base/files/file_enumerator.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "base/files/file_enumerator.h" 6 | 7 | #include "base/files/file_util.h" 8 | 9 | namespace base { 10 | 11 | FileEnumerator::FileInfo::~FileInfo() = default; 12 | 13 | bool FileEnumerator::ShouldSkip(const FilePath& path) { 14 | FilePath::StringType basename = path.BaseName().value(); 15 | return basename == FILE_PATH_LITERAL(".") || 16 | (basename == FILE_PATH_LITERAL("..") && 17 | !(INCLUDE_DOT_DOT & file_type_)); 18 | } 19 | 20 | bool FileEnumerator::IsTypeMatched(bool is_dir) const { 21 | return (file_type_ & 22 | (is_dir ? FileEnumerator::DIRECTORIES : FileEnumerator::FILES)) != 0; 23 | } 24 | 25 | } // namespace base 26 | -------------------------------------------------------------------------------- /src/base/files/file_path_constants.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include "base/files/file_path.h" 10 | 11 | namespace base { 12 | 13 | #if defined(FILE_PATH_USES_WIN_SEPARATORS) 14 | const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("\\/"); 15 | #else // FILE_PATH_USES_WIN_SEPARATORS 16 | const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("/"); 17 | #endif // FILE_PATH_USES_WIN_SEPARATORS 18 | 19 | const size_t FilePath::kSeparatorsLength = std::size(kSeparators); 20 | 21 | const FilePath::CharType FilePath::kCurrentDirectory[] = FILE_PATH_LITERAL("."); 22 | const FilePath::CharType FilePath::kParentDirectory[] = FILE_PATH_LITERAL(".."); 23 | 24 | const FilePath::CharType FilePath::kExtensionSeparator = FILE_PATH_LITERAL('.'); 25 | 26 | } // namespace base 27 | -------------------------------------------------------------------------------- /src/base/files/platform_file.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_FILES_PLATFORM_FILE_H_ 6 | #define BASE_FILES_PLATFORM_FILE_H_ 7 | 8 | #include "base/files/scoped_file.h" 9 | #include "util/build_config.h" 10 | 11 | #if defined(OS_WIN) 12 | #include "base/win/scoped_handle.h" 13 | #include 14 | #endif 15 | 16 | // This file defines platform-independent types for dealing with 17 | // platform-dependent files. If possible, use the higher-level base::File class 18 | // rather than these primitives. 19 | 20 | namespace base { 21 | 22 | #if defined(OS_WIN) 23 | 24 | using PlatformFile = HANDLE; 25 | using ScopedPlatformFile = ::base::win::ScopedHandle; 26 | 27 | // It would be nice to make this constexpr but INVALID_HANDLE_VALUE is a 28 | // ((void*)(-1)) which Clang rejects since reinterpret_cast is technically 29 | // disallowed in constexpr. Visual Studio accepts this, however. 30 | const PlatformFile kInvalidPlatformFile = INVALID_HANDLE_VALUE; 31 | 32 | #elif defined(OS_POSIX) || defined(OS_FUCHSIA) 33 | 34 | using PlatformFile = int; 35 | using ScopedPlatformFile = ::base::ScopedFD; 36 | 37 | constexpr PlatformFile kInvalidPlatformFile = -1; 38 | 39 | #endif 40 | 41 | } // namespace base 42 | 43 | #endif // BASE_FILES_PLATFORM_FILE_H_ 44 | -------------------------------------------------------------------------------- /src/base/gtest_prod_util.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_GTEST_PROD_UTIL_H_ 6 | #define BASE_GTEST_PROD_UTIL_H_ 7 | 8 | // TODO: Remove me. 9 | #define FRIEND_TEST_ALL_PREFIXES(test_case_name, test_name) \ 10 | friend struct test_case_name##test_name 11 | 12 | #endif // BASE_GTEST_PROD_UTIL_H_ 13 | -------------------------------------------------------------------------------- /src/base/json/json_value_converter.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "base/json/json_value_converter.h" 6 | 7 | namespace base { 8 | namespace internal { 9 | 10 | bool BasicValueConverter::Convert(const base::Value& value, 11 | int* field) const { 12 | return value.GetAsInteger(field); 13 | } 14 | 15 | bool BasicValueConverter::Convert(const base::Value& value, 16 | std::string* field) const { 17 | return value.GetAsString(field); 18 | } 19 | 20 | bool BasicValueConverter::Convert(const base::Value& value, 21 | std::u16string* field) const { 22 | return value.GetAsString(field); 23 | } 24 | 25 | bool BasicValueConverter::Convert(const base::Value& value, 26 | double* field) const { 27 | return value.GetAsDouble(field); 28 | } 29 | 30 | bool BasicValueConverter::Convert(const base::Value& value, 31 | bool* field) const { 32 | return value.GetAsBoolean(field); 33 | } 34 | 35 | } // namespace internal 36 | } // namespace base 37 | -------------------------------------------------------------------------------- /src/base/mac/mac_logging.mm: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "base/mac/mac_logging.h" 6 | 7 | #import 8 | 9 | #include 10 | 11 | #include "util/build_config.h" 12 | 13 | #if !defined(OS_IOS) 14 | #include 15 | #endif 16 | 17 | namespace logging { 18 | 19 | std::string DescriptionFromOSStatus(OSStatus err) { 20 | NSError* error = 21 | [NSError errorWithDomain:NSOSStatusErrorDomain code:err userInfo:nil]; 22 | return error.description.UTF8String; 23 | } 24 | 25 | OSStatusLogMessage::OSStatusLogMessage(const char* file_path, 26 | int line, 27 | LogSeverity severity, 28 | OSStatus status) 29 | : LogMessage(file_path, line, severity), status_(status) {} 30 | 31 | OSStatusLogMessage::~OSStatusLogMessage() { 32 | #if defined(OS_IOS) 33 | // TODO(crbug.com/546375): Consider using NSError with NSOSStatusErrorDomain 34 | // to try to get a description of the failure. 35 | stream() << ": " << status_; 36 | #else 37 | stream() << ": " << DescriptionFromOSStatus(status_) << " (" << status_ 38 | << ")"; 39 | #endif 40 | } 41 | 42 | } // namespace logging 43 | -------------------------------------------------------------------------------- /src/base/memory/free_deleter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_MEMORY_FREE_DELETER_H_ 6 | #define BASE_MEMORY_FREE_DELETER_H_ 7 | 8 | #include 9 | 10 | namespace base { 11 | 12 | // Function object which invokes 'free' on its parameter, which must be 13 | // a pointer. Can be used to store malloc-allocated pointers in std::unique_ptr: 14 | // 15 | // std::unique_ptr foo_ptr( 16 | // static_cast(malloc(sizeof(int)))); 17 | struct FreeDeleter { 18 | inline void operator()(void* ptr) const { free(ptr); } 19 | }; 20 | 21 | } // namespace base 22 | 23 | #endif // BASE_MEMORY_FREE_DELETER_H_ 24 | -------------------------------------------------------------------------------- /src/base/memory/ptr_util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_MEMORY_PTR_UTIL_H_ 6 | #define BASE_MEMORY_PTR_UTIL_H_ 7 | 8 | #include 9 | #include 10 | 11 | namespace base { 12 | 13 | // Helper to transfer ownership of a raw pointer to a std::unique_ptr. 14 | // Note that std::unique_ptr has very different semantics from 15 | // std::unique_ptr: do not use this helper for array allocations. 16 | template 17 | std::unique_ptr WrapUnique(T* ptr) { 18 | return std::unique_ptr(ptr); 19 | } 20 | 21 | } // namespace base 22 | 23 | #endif // BASE_MEMORY_PTR_UTIL_H_ 24 | -------------------------------------------------------------------------------- /src/base/memory/ref_counted.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "base/memory/ref_counted.h" 6 | 7 | namespace base { 8 | 9 | namespace subtle { 10 | 11 | bool RefCountedThreadSafeBase::HasOneRef() const { 12 | return ref_count_.IsOne(); 13 | } 14 | 15 | #if defined(ARCH_CPU_64_BIT) 16 | void RefCountedBase::AddRefImpl() const { 17 | // Check if |ref_count_| overflow only on 64 bit archs since the number of 18 | // objects may exceed 2^32. 19 | // To avoid the binary size bloat, use non-inline function here. 20 | CHECK(++ref_count_ > 0); 21 | } 22 | #endif 23 | 24 | #if !defined(ARCH_CPU_X86_FAMILY) 25 | bool RefCountedThreadSafeBase::Release() const { 26 | return ReleaseImpl(); 27 | } 28 | void RefCountedThreadSafeBase::AddRef() const { 29 | AddRefImpl(); 30 | } 31 | #endif 32 | 33 | } // namespace subtle 34 | 35 | } // namespace base 36 | -------------------------------------------------------------------------------- /src/base/memory/scoped_policy.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_MEMORY_SCOPED_POLICY_H_ 6 | #define BASE_MEMORY_SCOPED_POLICY_H_ 7 | 8 | namespace base { 9 | namespace scoped_policy { 10 | 11 | // Defines the ownership policy for a scoped object. 12 | enum OwnershipPolicy { 13 | // The scoped object takes ownership of an object by taking over an existing 14 | // ownership claim. 15 | ASSUME, 16 | 17 | // The scoped object will retain the the object and any initial ownership is 18 | // not changed. 19 | RETAIN 20 | }; 21 | 22 | } // namespace scoped_policy 23 | } // namespace base 24 | 25 | #endif // BASE_MEMORY_SCOPED_POLICY_H_ 26 | -------------------------------------------------------------------------------- /src/base/numerics/math_constants.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_NUMERICS_MATH_CONSTANTS_H_ 6 | #define BASE_NUMERICS_MATH_CONSTANTS_H_ 7 | 8 | namespace base { 9 | 10 | constexpr double kPiDouble = 3.14159265358979323846; 11 | constexpr float kPiFloat = 3.14159265358979323846f; 12 | 13 | } // namespace base 14 | 15 | #endif // BASE_NUMERICS_MATH_CONSTANTS_H_ 16 | -------------------------------------------------------------------------------- /src/base/numerics/ranges.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_NUMERICS_RANGES_H_ 6 | #define BASE_NUMERICS_RANGES_H_ 7 | 8 | #include 9 | #include 10 | 11 | namespace base { 12 | 13 | // To be replaced with std::clamp() from C++17, someday. 14 | template 15 | constexpr const T& ClampToRange(const T& value, const T& min, const T& max) { 16 | return std::min(std::max(value, min), max); 17 | } 18 | 19 | template 20 | constexpr bool IsApproximatelyEqual(T lhs, T rhs, T tolerance) { 21 | static_assert(std::is_arithmetic::value, "Argument must be arithmetic"); 22 | return std::abs(rhs - lhs) <= tolerance; 23 | } 24 | 25 | } // namespace base 26 | 27 | #endif // BASE_NUMERICS_RANGES_H_ 28 | -------------------------------------------------------------------------------- /src/base/numerics/safe_math.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_NUMERICS_SAFE_MATH_H_ 6 | #define BASE_NUMERICS_SAFE_MATH_H_ 7 | 8 | #include "base/numerics/checked_math.h" 9 | #include "base/numerics/clamped_math.h" 10 | #include "base/numerics/safe_conversions.h" 11 | 12 | #endif // BASE_NUMERICS_SAFE_MATH_H_ 13 | -------------------------------------------------------------------------------- /src/base/scoped_clear_errno.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_SCOPED_CLEAR_ERRNO_H_ 6 | #define BASE_SCOPED_CLEAR_ERRNO_H_ 7 | 8 | #include 9 | 10 | namespace base { 11 | 12 | // Simple scoper that saves the current value of errno, resets it to 0, and on 13 | // destruction puts the old value back. 14 | class ScopedClearErrno { 15 | public: 16 | ScopedClearErrno() : old_errno_(errno) { errno = 0; } 17 | ~ScopedClearErrno() { 18 | if (errno == 0) 19 | errno = old_errno_; 20 | } 21 | 22 | private: 23 | const int old_errno_; 24 | 25 | ScopedClearErrno(const ScopedClearErrno&) = delete; 26 | ScopedClearErrno& operator=(const ScopedClearErrno&) = delete; 27 | }; 28 | 29 | } // namespace base 30 | 31 | #endif // BASE_SCOPED_CLEAR_ERRNO_H_ 32 | -------------------------------------------------------------------------------- /src/base/sha1.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_SHA1_H_ 6 | #define BASE_SHA1_H_ 7 | 8 | #include 9 | 10 | #include 11 | 12 | namespace base { 13 | 14 | // These functions perform SHA-1 operations. 15 | 16 | static const size_t kSHA1Length = 20; // Length in bytes of a SHA-1 hash. 17 | 18 | // Computes the SHA-1 hash of the input string |str| and returns the full 19 | // hash. 20 | std::string SHA1HashString(const std::string& str); 21 | 22 | // Computes the SHA-1 hash of the |len| bytes in |data| and puts the hash 23 | // in |hash|. |hash| must be kSHA1Length bytes long. 24 | void SHA1HashBytes(const unsigned char* data, size_t len, unsigned char* hash); 25 | 26 | } // namespace base 27 | 28 | #endif // BASE_SHA1_H_ 29 | -------------------------------------------------------------------------------- /src/base/strings/string_util_posix.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_STRINGS_STRING_UTIL_POSIX_H_ 6 | #define BASE_STRINGS_STRING_UTIL_POSIX_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "base/logging.h" 13 | 14 | namespace base { 15 | 16 | inline int vsnprintf(char* buffer, 17 | size_t size, 18 | const char* format, 19 | va_list arguments) { 20 | return ::vsnprintf(buffer, size, format, arguments); 21 | } 22 | 23 | } // namespace base 24 | 25 | #endif // BASE_STRINGS_STRING_UTIL_POSIX_H_ 26 | -------------------------------------------------------------------------------- /src/base/strings/string_util_win.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_STRINGS_STRING_UTIL_WIN_H_ 6 | #define BASE_STRINGS_STRING_UTIL_WIN_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "base/logging.h" 14 | 15 | namespace base { 16 | 17 | inline int vsnprintf(char* buffer, 18 | size_t size, 19 | const char* format, 20 | va_list arguments) { 21 | int length = vsnprintf_s(buffer, size, size - 1, format, arguments); 22 | if (length < 0) 23 | return _vscprintf(format, arguments); 24 | return length; 25 | } 26 | 27 | } // namespace base 28 | 29 | #endif // BASE_STRINGS_STRING_UTIL_WIN_H_ 30 | -------------------------------------------------------------------------------- /src/base/strings/stringize_macros.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | // 5 | // This file defines preprocessor macros for stringizing preprocessor 6 | // symbols (or their output) and manipulating preprocessor symbols 7 | // that define strings. 8 | 9 | #ifndef BASE_STRINGS_STRINGIZE_MACROS_H_ 10 | #define BASE_STRINGS_STRINGIZE_MACROS_H_ 11 | 12 | #include "util/build_config.h" 13 | 14 | // This is not very useful as it does not expand defined symbols if 15 | // called directly. Use its counterpart without the _NO_EXPANSION 16 | // suffix, below. 17 | #define STRINGIZE_NO_EXPANSION(x) #x 18 | 19 | // Use this to quote the provided parameter, first expanding it if it 20 | // is a preprocessor symbol. 21 | // 22 | // For example, if: 23 | // #define A FOO 24 | // #define B(x) myobj->FunctionCall(x) 25 | // 26 | // Then: 27 | // STRINGIZE(A) produces "FOO" 28 | // STRINGIZE(B(y)) produces "myobj->FunctionCall(y)" 29 | #define STRINGIZE(x) STRINGIZE_NO_EXPANSION(x) 30 | 31 | #endif // BASE_STRINGS_STRINGIZE_MACROS_H_ 32 | -------------------------------------------------------------------------------- /src/base/strings/utf_string_conversions.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_STRINGS_UTF_STRING_CONVERSIONS_H_ 6 | #define BASE_STRINGS_UTF_STRING_CONVERSIONS_H_ 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | namespace base { 14 | 15 | bool UTF8ToUTF16(const char* src, size_t src_len, std::u16string* output); 16 | std::u16string UTF8ToUTF16(std::string_view utf8); 17 | bool UTF16ToUTF8(const char16_t* src, size_t src_len, std::string* output); 18 | std::string UTF16ToUTF8(std::u16string_view utf16); 19 | 20 | // This converts an ASCII string, typically a hardcoded constant, to a UTF16 21 | // string. 22 | std::u16string ASCIIToUTF16(std::string_view ascii); 23 | 24 | // Converts to 7-bit ASCII by truncating. The result must be known to be ASCII 25 | // beforehand. 26 | std::string UTF16ToASCII(std::u16string_view utf16); 27 | 28 | } // namespace base 29 | 30 | #endif // BASE_STRINGS_UTF_STRING_CONVERSIONS_H_ 31 | -------------------------------------------------------------------------------- /src/base/template_util.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_TEMPLATE_UTIL_H_ 6 | #define BASE_TEMPLATE_UTIL_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace base { 14 | 15 | namespace internal { 16 | 17 | // Uses expression SFINAE to detect whether using operator<< would work. 18 | template 19 | struct SupportsOstreamOperator : std::false_type {}; 20 | template 21 | struct SupportsOstreamOperator() 23 | << std::declval()))> 24 | : std::true_type {}; 25 | 26 | // Used to detech whether the given type is an iterator. This is normally used 27 | // with std::enable_if to provide disambiguation for functions that take 28 | // templatzed iterators as input. 29 | template 30 | struct is_iterator : std::false_type {}; 31 | 32 | template 33 | struct is_iterator< 34 | T, 35 | std::void_t::iterator_category>> 36 | : std::true_type {}; 37 | 38 | } // namespace internal 39 | 40 | } // namespace base 41 | 42 | #endif // BASE_TEMPLATE_UTIL_H_ 43 | -------------------------------------------------------------------------------- /src/base/third_party/icu/README.chromium: -------------------------------------------------------------------------------- 1 | Name: ICU 2 | URL: http://site.icu-project.org/ 3 | Version: 60 4 | License: Unicode 5 | License File: NOT_SHIPPED 6 | 7 | This file has the relevant components from ICU copied to handle basic UTF8/16/32 8 | conversions. Components are copied from umachine.h, utf.h, utf8.h, and utf16.h 9 | into icu_utf.h, and from utf_impl.cpp into icu_utf.cc. 10 | 11 | The main change is that U_/U8_/U16_ prefixes have been replaced with 12 | CBU_/CBU8_/CBU16_ (for "Chrome Base") to avoid confusion with the "real" ICU 13 | macros should ICU be in use on the system. For the same reason, the functions 14 | and types have been put in the "base_icu" namespace. 15 | 16 | Note that this license file is marked as NOT_SHIPPED, since a more complete 17 | ICU license is included from //third_party/icu/README.chromium 18 | -------------------------------------------------------------------------------- /src/base/timer/elapsed_timer.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "base/timer/elapsed_timer.h" 6 | 7 | namespace base { 8 | 9 | ElapsedTimer::ElapsedTimer() { 10 | begin_ = TicksNow(); 11 | } 12 | 13 | ElapsedTimer::ElapsedTimer(ElapsedTimer&& other) { 14 | begin_ = other.begin_; 15 | } 16 | 17 | void ElapsedTimer::operator=(ElapsedTimer&& other) { 18 | begin_ = other.begin_; 19 | } 20 | 21 | TickDelta ElapsedTimer::Elapsed() const { 22 | return TicksDelta(TicksNow(), begin_); 23 | } 24 | 25 | } // namespace base 26 | -------------------------------------------------------------------------------- /src/base/timer/elapsed_timer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_TIMER_ELAPSED_TIMER_H_ 6 | #define BASE_TIMER_ELAPSED_TIMER_H_ 7 | 8 | #include "util/ticks.h" 9 | 10 | namespace base { 11 | 12 | // A simple wrapper around TicksNow(). 13 | class ElapsedTimer { 14 | public: 15 | ElapsedTimer(); 16 | ElapsedTimer(ElapsedTimer&& other); 17 | 18 | void operator=(ElapsedTimer&& other); 19 | 20 | // Returns the time elapsed since object construction. 21 | TickDelta Elapsed() const; 22 | 23 | private: 24 | Ticks begin_; 25 | 26 | ElapsedTimer(const ElapsedTimer&) = delete; 27 | ElapsedTimer& operator=(const ElapsedTimer&) = delete; 28 | }; 29 | 30 | } // namespace base 31 | 32 | #endif // BASE_TIMER_ELAPSED_TIMER_H_ 33 | -------------------------------------------------------------------------------- /src/base/win/scoped_handle.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "base/win/scoped_handle.h" 6 | #include 7 | 8 | namespace base { 9 | namespace win { 10 | 11 | // Static. 12 | bool HandleTraits::CloseHandle(HANDLE handle) { 13 | return ::CloseHandle(handle); 14 | } 15 | 16 | // Static. 17 | void VerifierTraits::StartTracking(HANDLE handle, 18 | const void* owner, 19 | const void* pc1, 20 | const void* pc2) {} 21 | 22 | // Static. 23 | void VerifierTraits::StopTracking(HANDLE handle, 24 | const void* owner, 25 | const void* pc1, 26 | const void* pc2) {} 27 | 28 | void DisableHandleVerifier() {} 29 | 30 | void OnHandleBeingClosed(HANDLE handle) {} 31 | 32 | } // namespace win 33 | } // namespace base 34 | -------------------------------------------------------------------------------- /src/base/win/win_util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_WIN_WIN_UTIL_H_ 6 | #define BASE_WIN_WIN_UTIL_H_ 7 | 8 | #include 9 | #include 10 | 11 | namespace base { 12 | 13 | // Windows API calls take wchar_t but on that platform wchar_t should be the 14 | // same as a char16_t. 15 | inline const wchar_t* ToWCharT(const std::u16string* s) { 16 | static_assert(sizeof(std::u16string::value_type) == sizeof(wchar_t)); 17 | return reinterpret_cast(s->c_str()); 18 | } 19 | 20 | inline const wchar_t* ToWCharT(const char16_t* s) { 21 | return reinterpret_cast(s); 22 | } 23 | 24 | inline wchar_t* ToWCharT(char16_t* s) { 25 | return reinterpret_cast(s); 26 | } 27 | 28 | } // namespace base 29 | 30 | #endif // BASE_WIN_WIN_UTIL_H_ 31 | -------------------------------------------------------------------------------- /src/gn/action_target_generator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_ACTION_TARGET_GENERATOR_H_ 6 | #define TOOLS_GN_ACTION_TARGET_GENERATOR_H_ 7 | 8 | #include "gn/target.h" 9 | #include "gn/target_generator.h" 10 | 11 | // Populates a Target with the values from an action[_foreach] rule. 12 | class ActionTargetGenerator : public TargetGenerator { 13 | public: 14 | ActionTargetGenerator(Target* target, 15 | Scope* scope, 16 | const FunctionCallNode* function_call, 17 | Target::OutputType type, 18 | Err* err); 19 | ~ActionTargetGenerator() override; 20 | 21 | protected: 22 | void DoRun() override; 23 | 24 | private: 25 | bool FillScript(); 26 | bool FillScriptArgs(); 27 | bool FillResponseFileContents(); 28 | bool FillDepfile(); 29 | bool FillPool(); 30 | bool FillInputs(); 31 | 32 | // Checks for errors in the outputs variable. 33 | bool CheckOutputs(); 34 | 35 | Target::OutputType output_type_; 36 | 37 | ActionTargetGenerator(const ActionTargetGenerator&) = delete; 38 | ActionTargetGenerator& operator=(const ActionTargetGenerator&) = delete; 39 | }; 40 | 41 | #endif // TOOLS_GN_ACTION_TARGET_GENERATOR_H_ 42 | -------------------------------------------------------------------------------- /src/gn/action_values.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/action_values.h" 6 | 7 | #include "gn/settings.h" 8 | #include "gn/substitution_writer.h" 9 | #include "gn/target.h" 10 | 11 | ActionValues::ActionValues() = default; 12 | 13 | ActionValues::~ActionValues() = default; 14 | 15 | void ActionValues::GetOutputsAsSourceFiles( 16 | const Target* target, 17 | std::vector* result) const { 18 | if (target->output_type() == Target::BUNDLE_DATA) { 19 | // The bundle_data target has no output, the real output will be generated 20 | // by the create_bundle target. 21 | } else if (target->output_type() == Target::COPY_FILES || 22 | target->output_type() == Target::ACTION_FOREACH) { 23 | // Copy and foreach applies the outputs to the sources. 24 | SubstitutionWriter::ApplyListToSources(target, target->settings(), outputs_, 25 | target->sources(), result); 26 | } else { 27 | // Actions (and anything else that happens to specify an output) just use 28 | // the output list with no substitution. 29 | SubstitutionWriter::GetListAsSourceFiles(outputs_, result); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/gn/bundle_data_target_generator.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_BUNDLE_DATA_TARGET_GENERATOR_H_ 6 | #define TOOLS_GN_BUNDLE_DATA_TARGET_GENERATOR_H_ 7 | 8 | #include "gn/target_generator.h" 9 | 10 | // Populates a Target with the values from a bundle_data rule. 11 | class BundleDataTargetGenerator : public TargetGenerator { 12 | public: 13 | BundleDataTargetGenerator(Target* target, 14 | Scope* scope, 15 | const FunctionCallNode* function_call, 16 | Err* err); 17 | ~BundleDataTargetGenerator() override; 18 | 19 | protected: 20 | void DoRun() override; 21 | 22 | private: 23 | bool FillOutputs(); 24 | 25 | bool EnsureSubstitutionIsInBundleDir(const SubstitutionPattern& pattern, 26 | const Value& original_value); 27 | 28 | BundleDataTargetGenerator(const BundleDataTargetGenerator&) = delete; 29 | BundleDataTargetGenerator& operator=(const BundleDataTargetGenerator&) = 30 | delete; 31 | }; 32 | 33 | #endif // TOOLS_GN_BUNDLE_DATA_TARGET_GENERATOR_H_ 34 | -------------------------------------------------------------------------------- /src/gn/command_format.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_COMAND_FORMAT_H_ 6 | #define TOOLS_GN_COMAND_FORMAT_H_ 7 | 8 | #include 9 | 10 | class Setup; 11 | class SourceFile; 12 | 13 | namespace commands { 14 | 15 | enum class TreeDumpMode { 16 | // Normal operation mode. Format the input file. 17 | kInactive, 18 | 19 | // Output the token tree with indented plain text. For debugging. 20 | kPlainText, 21 | 22 | // Output the token tree in JSON format. Used for exporting a tree to another 23 | // program. 24 | kJSON 25 | }; 26 | 27 | bool FormatJsonToString(const std::string& input, std::string* output); 28 | 29 | bool FormatStringToString(const std::string& input, 30 | TreeDumpMode dump_tree, 31 | std::string* output, 32 | std::string* dump_output); 33 | 34 | } // namespace commands 35 | 36 | #endif // TOOLS_GN_COMAND_FORMAT_H_ 37 | -------------------------------------------------------------------------------- /src/gn/commands_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include 6 | 7 | #include "gn/commands.h" 8 | #include "gn/label_pattern.h" 9 | #include "gn/target.h" 10 | #include "gn/test_with_scope.h" 11 | #include "util/test/test.h" 12 | 13 | TEST(Commands, FilterOutMatch) { 14 | TestWithScope setup; 15 | SourceDir current_dir("//"); 16 | 17 | Target target_afoo(setup.settings(), Label(SourceDir("//a/"), "foo")); 18 | Target target_cbar(setup.settings(), Label(SourceDir("//c/"), "bar")); 19 | std::vector targets{&target_afoo, &target_cbar}; 20 | 21 | Err err; 22 | LabelPattern pattern_a = LabelPattern::GetPattern( 23 | current_dir, std::string_view(), Value(nullptr, "//a:*"), &err); 24 | EXPECT_FALSE(err.has_error()); 25 | LabelPattern pattern_ef = LabelPattern::GetPattern( 26 | current_dir, std::string_view(), Value(nullptr, "//e:f"), &err); 27 | EXPECT_FALSE(err.has_error()); 28 | std::vector label_patterns{pattern_a, pattern_ef}; 29 | 30 | std::vector output; 31 | commands::FilterOutTargetsByPatterns(targets, label_patterns, &output); 32 | 33 | EXPECT_EQ(1, output.size()); 34 | EXPECT_EQ(&target_cbar, output[0]); 35 | } 36 | -------------------------------------------------------------------------------- /src/gn/config_values_extractors.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/config_values_extractors.h" 6 | 7 | #include "gn/escape.h" 8 | 9 | namespace { 10 | 11 | class EscapedStringWriter { 12 | public: 13 | explicit EscapedStringWriter(const EscapeOptions& escape_options) 14 | : escape_options_(escape_options) {} 15 | 16 | void operator()(const std::string& s, std::ostream& out) const { 17 | out << " "; 18 | EscapeStringToStream(out, s, escape_options_); 19 | } 20 | 21 | private: 22 | const EscapeOptions& escape_options_; 23 | }; 24 | 25 | } // namespace 26 | 27 | void RecursiveTargetConfigStringsToStream( 28 | RecursiveWriterConfig config, 29 | const Target* target, 30 | const std::vector& (ConfigValues::*getter)() const, 31 | const EscapeOptions& escape_options, 32 | std::ostream& out) { 33 | RecursiveTargetConfigToStream(config, target, getter, 34 | EscapedStringWriter(escape_options), out); 35 | } 36 | -------------------------------------------------------------------------------- /src/gn/copy_target_generator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_COPY_TARGET_GENERATOR_H_ 6 | #define TOOLS_GN_COPY_TARGET_GENERATOR_H_ 7 | 8 | #include "gn/target_generator.h" 9 | 10 | // Populates a Target with the values from a copy rule. 11 | class CopyTargetGenerator : public TargetGenerator { 12 | public: 13 | CopyTargetGenerator(Target* target, 14 | Scope* scope, 15 | const FunctionCallNode* function_call, 16 | Err* err); 17 | ~CopyTargetGenerator() override; 18 | 19 | protected: 20 | void DoRun() override; 21 | 22 | private: 23 | CopyTargetGenerator(const CopyTargetGenerator&) = delete; 24 | CopyTargetGenerator& operator=(const CopyTargetGenerator&) = delete; 25 | }; 26 | 27 | #endif // TOOLS_GN_COPY_TARGET_GENERATOR_H_ 28 | -------------------------------------------------------------------------------- /src/gn/desc_builder.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_DESC_BUILDER_H_ 6 | #define TOOLS_GN_DESC_BUILDER_H_ 7 | 8 | #include "base/values.h" 9 | #include "gn/target.h" 10 | 11 | class DescBuilder { 12 | public: 13 | // Creates Dictionary representation for given target 14 | static std::unique_ptr DescriptionForTarget( 15 | const Target* target, 16 | const std::string& what, 17 | bool all, 18 | bool tree, 19 | bool blame); 20 | 21 | // Creates Dictionary representation for given config 22 | static std::unique_ptr DescriptionForConfig( 23 | const Config* config, 24 | const std::string& what); 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/gn/exec_process.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_EXEC_PROCESS_H_ 6 | #define TOOLS_GN_EXEC_PROCESS_H_ 7 | 8 | #include 9 | 10 | #include "util/build_config.h" 11 | 12 | namespace base { 13 | class CommandLine; 14 | class FilePath; 15 | } // namespace base 16 | 17 | namespace internal { 18 | 19 | bool ExecProcess(const base::CommandLine& cmdline, 20 | const base::FilePath& startup_dir, 21 | std::string* std_out, 22 | std::string* std_err, 23 | int* exit_code); 24 | 25 | #if defined(OS_WIN) 26 | bool ExecProcess(const std::u16string& cmdline_str, 27 | const base::FilePath& startup_dir, 28 | std::string* std_out, 29 | std::string* std_err, 30 | int* exit_code); 31 | #endif // OS_WIN 32 | 33 | } // namespace internal 34 | 35 | #endif // TOOLS_GN_EXEC_PROCESS_H_ 36 | -------------------------------------------------------------------------------- /src/gn/file_writer_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/file_writer.h" 6 | 7 | #include "base/files/file_path.h" 8 | #include "base/files/scoped_temp_dir.h" 9 | #include "gn/filesystem_utils.h" 10 | 11 | #include "util/test/test.h" 12 | 13 | TEST(FileWriter, SingleWrite) { 14 | base::ScopedTempDir temp_dir; 15 | ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 16 | 17 | std::string data = "foo"; 18 | 19 | base::FilePath file_path = temp_dir.GetPath().AppendASCII("foo.txt"); 20 | 21 | FileWriter writer; 22 | EXPECT_TRUE(writer.Create(file_path)); 23 | EXPECT_TRUE(writer.Write(data)); 24 | EXPECT_TRUE(writer.Close()); 25 | 26 | EXPECT_TRUE(ContentsEqual(file_path, data)); 27 | } 28 | 29 | TEST(FileWriter, MultipleWrites) { 30 | base::ScopedTempDir temp_dir; 31 | ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 32 | 33 | std::string data = "Hello World!"; 34 | 35 | base::FilePath file_path = temp_dir.GetPath().AppendASCII("foo.txt"); 36 | 37 | FileWriter writer; 38 | EXPECT_TRUE(writer.Create(file_path)); 39 | EXPECT_TRUE(writer.Write("Hello ")); 40 | EXPECT_TRUE(writer.Write("World!")); 41 | EXPECT_TRUE(writer.Close()); 42 | 43 | EXPECT_TRUE(ContentsEqual(file_path, data)); 44 | } 45 | -------------------------------------------------------------------------------- /src/gn/format_test_data/001.gn: -------------------------------------------------------------------------------- 1 | # Test. 2 | executable("test"){} 3 | -------------------------------------------------------------------------------- /src/gn/format_test_data/001.golden: -------------------------------------------------------------------------------- 1 | # Test. 2 | executable("test") { 3 | } 4 | -------------------------------------------------------------------------------- /src/gn/format_test_data/002.gn: -------------------------------------------------------------------------------- 1 | executable("test") { 2 | sources = [ 3 | "stuff.cc", 4 | "things.cc" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /src/gn/format_test_data/002.golden: -------------------------------------------------------------------------------- 1 | executable("test") { 2 | sources = [ 3 | "stuff.cc", 4 | "things.cc", 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /src/gn/format_test_data/003.gn: -------------------------------------------------------------------------------- 1 | executable("test") { 2 | sources = [ 3 | "stuff.cc", 4 | "things.cc" 5 | ] 6 | 7 | deps = [ 8 | "//base", 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/gn/format_test_data/003.golden: -------------------------------------------------------------------------------- 1 | executable("test") { 2 | sources = [ 3 | "stuff.cc", 4 | "things.cc", 5 | ] 6 | 7 | deps = [ "//base" ] 8 | } 9 | -------------------------------------------------------------------------------- /src/gn/format_test_data/004.gn: -------------------------------------------------------------------------------- 1 | # This is a block comment that goes at the top of the file and is attached to 2 | # the top level target. 3 | executable("test") { 4 | sources = [ 5 | "stuff.cc",# Comment attached to list item. 6 | "things.cc" 7 | ] 8 | # Comment attached to statement. 9 | deps = [ "//base", ] 10 | } 11 | -------------------------------------------------------------------------------- /src/gn/format_test_data/004.golden: -------------------------------------------------------------------------------- 1 | # This is a block comment that goes at the top of the file and is attached to 2 | # the top level target. 3 | executable("test") { 4 | sources = [ 5 | "stuff.cc", # Comment attached to list item. 6 | "things.cc", 7 | ] 8 | 9 | # Comment attached to statement. 10 | deps = [ "//base" ] 11 | } 12 | -------------------------------------------------------------------------------- /src/gn/format_test_data/005.gn: -------------------------------------------------------------------------------- 1 | # This is a separated block comment that mustn't be attached the to target 2 | # below, and should be separated by a single blank line. 3 | 4 | executable("test") { 5 | } 6 | -------------------------------------------------------------------------------- /src/gn/format_test_data/005.golden: -------------------------------------------------------------------------------- 1 | # This is a separated block comment that mustn't be attached the to target 2 | # below, and should be separated by a single blank line. 3 | 4 | executable("test") { 5 | } 6 | -------------------------------------------------------------------------------- /src/gn/format_test_data/006.gn: -------------------------------------------------------------------------------- 1 | # This is a separated block comment that mustn't be attached the to target 2 | # below, and should be separated by a single blank line. 3 | 4 | 5 | 6 | 7 | 8 | executable("test") { 9 | } 10 | -------------------------------------------------------------------------------- /src/gn/format_test_data/006.golden: -------------------------------------------------------------------------------- 1 | # This is a separated block comment that mustn't be attached the to target 2 | # below, and should be separated by a single blank line. 3 | 4 | executable("test") { 5 | } 6 | -------------------------------------------------------------------------------- /src/gn/format_test_data/007.gn: -------------------------------------------------------------------------------- 1 | executable("test") { 2 | sources = ["a.cc"] 3 | 4 | # This is an unusual comment that's a header for the stuff that comes after 5 | # it. We want to make sure that it's not connected to the next element in 6 | # the file. 7 | 8 | cflags = ["-Wee"] 9 | } 10 | -------------------------------------------------------------------------------- /src/gn/format_test_data/007.golden: -------------------------------------------------------------------------------- 1 | executable("test") { 2 | sources = [ "a.cc" ] 3 | 4 | # This is an unusual comment that's a header for the stuff that comes after 5 | # it. We want to make sure that it's not connected to the next element in 6 | # the file. 7 | 8 | cflags = [ "-Wee" ] 9 | } 10 | -------------------------------------------------------------------------------- /src/gn/format_test_data/008.gn: -------------------------------------------------------------------------------- 1 | if (is_win) { sources = ["win.cc"] } 2 | -------------------------------------------------------------------------------- /src/gn/format_test_data/008.golden: -------------------------------------------------------------------------------- 1 | if (is_win) { 2 | sources = [ "win.cc" ] 3 | } 4 | -------------------------------------------------------------------------------- /src/gn/format_test_data/009.gn: -------------------------------------------------------------------------------- 1 | if (is_win) { sources = ["win.cc"] } 2 | else { sources = ["linux.cc"] } 3 | -------------------------------------------------------------------------------- /src/gn/format_test_data/009.golden: -------------------------------------------------------------------------------- 1 | if (is_win) { 2 | sources = [ "win.cc" ] 3 | } else { 4 | sources = [ "linux.cc" ] 5 | } 6 | -------------------------------------------------------------------------------- /src/gn/format_test_data/010.gn: -------------------------------------------------------------------------------- 1 | if (is_win) { sources = ["win.cc"] } 2 | else if (is_linux) { sources = ["linux.cc"] } 3 | -------------------------------------------------------------------------------- /src/gn/format_test_data/010.golden: -------------------------------------------------------------------------------- 1 | if (is_win) { 2 | sources = [ "win.cc" ] 3 | } else if (is_linux) { 4 | sources = [ "linux.cc" ] 5 | } 6 | -------------------------------------------------------------------------------- /src/gn/format_test_data/011.gn: -------------------------------------------------------------------------------- 1 | if (is_win) { sources = ["win.cc"] } 2 | else if (is_linux) { sources = ["linux.cc"] } 3 | else { sources = ["wha.cc"] } 4 | 5 | -------------------------------------------------------------------------------- /src/gn/format_test_data/011.golden: -------------------------------------------------------------------------------- 1 | if (is_win) { 2 | sources = [ "win.cc" ] 3 | } else if (is_linux) { 4 | sources = [ "linux.cc" ] 5 | } else { 6 | sources = [ "wha.cc" ] 7 | } 8 | -------------------------------------------------------------------------------- /src/gn/format_test_data/012.gn: -------------------------------------------------------------------------------- 1 | # (A sample top level block comment) 2 | # Copyright 2014 The Chromium Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | if (is_win) { 7 | # This is some special stuff for Windows 8 | sources = ["win.cc"] } else if (is_linux) { 9 | 10 | # This is a block comment inside the linux block, but not attached. 11 | 12 | sources = ["linux.cc"] 13 | } else { 14 | # A comment with trailing spaces 15 | sources = ["wha.cc"] } 16 | 17 | -------------------------------------------------------------------------------- /src/gn/format_test_data/012.golden: -------------------------------------------------------------------------------- 1 | # (A sample top level block comment) 2 | # Copyright 2014 The Chromium Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | if (is_win) { 7 | # This is some special stuff for Windows 8 | sources = [ "win.cc" ] 9 | } else if (is_linux) { 10 | # This is a block comment inside the linux block, but not attached. 11 | 12 | sources = [ "linux.cc" ] 13 | } else { 14 | # A comment with trailing spaces 15 | sources = [ "wha.cc" ] 16 | } 17 | -------------------------------------------------------------------------------- /src/gn/format_test_data/013.gn: -------------------------------------------------------------------------------- 1 | defines = [ 2 | # Separate comment inside expression. 3 | 4 | # Connected comment. 5 | "WEE", 6 | "BLORPY", 7 | ] 8 | -------------------------------------------------------------------------------- /src/gn/format_test_data/013.golden: -------------------------------------------------------------------------------- 1 | defines = [ 2 | # Separate comment inside expression. 3 | 4 | # Connected comment. 5 | "WEE", 6 | "BLORPY", 7 | ] 8 | -------------------------------------------------------------------------------- /src/gn/format_test_data/014.gn: -------------------------------------------------------------------------------- 1 | defines = [ 2 | 3 | # Connected comment. 4 | "WEE", 5 | "BLORPY", 6 | ] 7 | -------------------------------------------------------------------------------- /src/gn/format_test_data/014.golden: -------------------------------------------------------------------------------- 1 | defines = [ 2 | # Connected comment. 3 | "WEE", 4 | "BLORPY", 5 | ] 6 | -------------------------------------------------------------------------------- /src/gn/format_test_data/015.gn: -------------------------------------------------------------------------------- 1 | if (is_win) { 2 | sources = ["a.cc"] 3 | # Some comment at end. 4 | } 5 | -------------------------------------------------------------------------------- /src/gn/format_test_data/015.golden: -------------------------------------------------------------------------------- 1 | if (is_win) { 2 | sources = [ "a.cc" ] 3 | # Some comment at end. 4 | } 5 | -------------------------------------------------------------------------------- /src/gn/format_test_data/016.gn: -------------------------------------------------------------------------------- 1 | something = !is_win && is_linux || is_mac && !(is_freebsd || is_ios) 2 | -------------------------------------------------------------------------------- /src/gn/format_test_data/016.golden: -------------------------------------------------------------------------------- 1 | something = (!is_win && is_linux) || (is_mac && !(is_freebsd || is_ios)) 2 | -------------------------------------------------------------------------------- /src/gn/format_test_data/017.gn: -------------------------------------------------------------------------------- 1 | executable("win" # Suffix comment on arg. 2 | # And a strangely positioned line comment for some reason 3 | ) { 4 | defines = [ # Defines comment, suffix at end position. 5 | ] 6 | 7 | deps = [ 8 | # Deps comment, should be forced multiline. 9 | ] 10 | sources = [ 11 | "a.cc" 12 | # End of single sources comment, should be forced multiline. 13 | ] 14 | # End of block comment. 15 | } 16 | -------------------------------------------------------------------------------- /src/gn/format_test_data/017.golden: -------------------------------------------------------------------------------- 1 | executable("win" # Suffix comment on arg. 2 | 3 | # And a strangely positioned line comment for some reason 4 | ) { 5 | defines = [] # Defines comment, suffix at end position. 6 | 7 | deps = [ 8 | # Deps comment, should be forced multiline. 9 | ] 10 | sources = [ 11 | "a.cc", 12 | # End of single sources comment, should be forced multiline. 13 | ] 14 | 15 | # End of block comment. 16 | } 17 | -------------------------------------------------------------------------------- /src/gn/format_test_data/018.gn: -------------------------------------------------------------------------------- 1 | # Don't crash when no block on a function call. 2 | 3 | import("wee.gni") 4 | -------------------------------------------------------------------------------- /src/gn/format_test_data/018.golden: -------------------------------------------------------------------------------- 1 | # Don't crash when no block on a function call. 2 | 3 | import("wee.gni") 4 | -------------------------------------------------------------------------------- /src/gn/format_test_data/019.gn: -------------------------------------------------------------------------------- 1 | # Make sure blank lines are maintained before comments in lists. 2 | 3 | deps = [ 4 | "//pdf", # Not compiled on Android in GYP yet, either. 5 | "//ppapi:ppapi_c", 6 | "//third_party/libusb", 7 | "//ui/keyboard", # Blocked on content. 8 | 9 | # Seems to not be compiled on Android. Otherwise it will need a config.h. 10 | "//third_party/libxslt", 11 | 12 | # Not relevant to Android. 13 | "//ash", 14 | "//gn", 15 | 16 | # Multiple line 17 | # comment 18 | # here. 19 | "//ui/aura", 20 | "//ui/display", 21 | "//ui/views", 22 | "//ui/views/controls/webview", 23 | ] 24 | -------------------------------------------------------------------------------- /src/gn/format_test_data/019.golden: -------------------------------------------------------------------------------- 1 | # Make sure blank lines are maintained before comments in lists. 2 | 3 | deps = [ 4 | "//pdf", # Not compiled on Android in GYP yet, either. 5 | "//ppapi:ppapi_c", 6 | "//third_party/libusb", 7 | "//ui/keyboard", # Blocked on content. 8 | 9 | # Seems to not be compiled on Android. Otherwise it will need a config.h. 10 | "//third_party/libxslt", 11 | 12 | # Not relevant to Android. 13 | "//ash", 14 | "//gn", 15 | 16 | # Multiple line 17 | # comment 18 | # here. 19 | "//ui/aura", 20 | "//ui/display", 21 | "//ui/views", 22 | "//ui/views/controls/webview", 23 | ] 24 | -------------------------------------------------------------------------------- /src/gn/format_test_data/020.gn: -------------------------------------------------------------------------------- 1 | cflags = [ 2 | "/wd4267", # size_t -> int. 3 | "/wd4324", # Structure was padded due to __declspec(align()), which is 4 | # uninteresting. 5 | ] 6 | -------------------------------------------------------------------------------- /src/gn/format_test_data/020.golden: -------------------------------------------------------------------------------- 1 | cflags = [ 2 | "/wd4267", # size_t -> int. 3 | "/wd4324", # Structure was padded due to __declspec(align()), which is 4 | # uninteresting. 5 | ] 6 | -------------------------------------------------------------------------------- /src/gn/format_test_data/022.gn: -------------------------------------------------------------------------------- 1 | executable(something[0]) { 2 | if (weeeeee.stuff) { 3 | x = a.b 4 | y = a[8] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/gn/format_test_data/022.golden: -------------------------------------------------------------------------------- 1 | executable(something[0]) { 2 | if (weeeeee.stuff) { 3 | x = a.b 4 | y = a[8] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/gn/format_test_data/024.gn: -------------------------------------------------------------------------------- 1 | somefunc(){} 2 | -------------------------------------------------------------------------------- /src/gn/format_test_data/024.golden: -------------------------------------------------------------------------------- 1 | somefunc() { 2 | } 3 | -------------------------------------------------------------------------------- /src/gn/format_test_data/025.gn: -------------------------------------------------------------------------------- 1 | # Various parenthesis maintenance/trimming. 2 | if ((a.b && c[d] + ((x < 4 || ((z + b)))))) { 3 | y = z - (y - (x - !(b-d))) 4 | a += ["a", "b", "c"] - (["x"] - ["y"]) 5 | } 6 | -------------------------------------------------------------------------------- /src/gn/format_test_data/025.golden: -------------------------------------------------------------------------------- 1 | # Various parenthesis maintenance/trimming. 2 | if (a.b && c[d] + (x < 4 || z + b)) { 3 | y = z - (y - (x - !(b - d))) 4 | a += [ 5 | "a", 6 | "b", 7 | "c", 8 | ] - ([ "x" ] - [ "y" ]) 9 | } 10 | -------------------------------------------------------------------------------- /src/gn/format_test_data/026.gn: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | args = [ 3 | rebase_path("$target_gen_dir/experimental-libraries.cc", root_build_dir), 4 | "EXPERIMENTAL", 5 | v8_compress_startup_data 6 | ] + rebase_path(sources, root_build_dir) 7 | -------------------------------------------------------------------------------- /src/gn/format_test_data/026.golden: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | args = 3 | [ 4 | rebase_path("$target_gen_dir/experimental-libraries.cc", root_build_dir), 5 | "EXPERIMENTAL", 6 | v8_compress_startup_data, 7 | ] + rebase_path(sources, root_build_dir) 8 | -------------------------------------------------------------------------------- /src/gn/format_test_data/027.gn: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = [ 3 | "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaa"] 4 | -------------------------------------------------------------------------------- /src/gn/format_test_data/027.golden: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = [ 3 | "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 4 | "aaaaaaaaaaaaaaaaaaaaaaaaa", 5 | ] 6 | -------------------------------------------------------------------------------- /src/gn/format_test_data/028.gn: -------------------------------------------------------------------------------- 1 | # Don't separate these. 2 | import("wee.gni") 3 | import("waa.gni") 4 | 5 | import("woo.gni") 6 | 7 | 8 | 9 | import("blah.gni") 10 | -------------------------------------------------------------------------------- /src/gn/format_test_data/028.golden: -------------------------------------------------------------------------------- 1 | # Don't separate these. 2 | import("waa.gni") 3 | import("wee.gni") 4 | 5 | import("woo.gni") 6 | 7 | import("blah.gni") 8 | -------------------------------------------------------------------------------- /src/gn/format_test_data/029.gn: -------------------------------------------------------------------------------- 1 | # Don't separate small simple statements. 2 | is_android = false 3 | is_chromeos = false 4 | is_ios = false 5 | is_linux -= false 6 | is_mac = true 7 | is_nacl = false 8 | is_posix += true 9 | is_win = false 10 | -------------------------------------------------------------------------------- /src/gn/format_test_data/029.golden: -------------------------------------------------------------------------------- 1 | # Don't separate small simple statements. 2 | is_android = false 3 | is_chromeos = false 4 | is_ios = false 5 | is_linux -= false 6 | is_mac = true 7 | is_nacl = false 8 | is_posix += true 9 | is_win = false 10 | -------------------------------------------------------------------------------- /src/gn/format_test_data/030.gn: -------------------------------------------------------------------------------- 1 | # Don't separate simple statements in a scope. 2 | 3 | import("//testing/test.gni") 4 | 5 | test("something") { 6 | if (is_linux) { 7 | sources -= [ "file_version_info_unittest.cc" ] 8 | sources += [ "nix/xdg_util_unittest.cc" ] 9 | defines = [ "USE_SYMBOLIZE" ] 10 | configs += [ "//build/config/linux:glib" ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/gn/format_test_data/030.golden: -------------------------------------------------------------------------------- 1 | # Don't separate simple statements in a scope. 2 | 3 | import("//testing/test.gni") 4 | 5 | test("something") { 6 | if (is_linux) { 7 | sources -= [ "file_version_info_unittest.cc" ] 8 | sources += [ "nix/xdg_util_unittest.cc" ] 9 | defines = [ "USE_SYMBOLIZE" ] 10 | configs += [ "//build/config/linux:glib" ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/gn/format_test_data/031.gn: -------------------------------------------------------------------------------- 1 | deps += [ 2 | ":packed_extra_resources", 3 | ":packed_resources", 4 | 5 | # This shouldn't crash. 6 | 7 | # This shouldn't crash 2. 8 | ] 9 | -------------------------------------------------------------------------------- /src/gn/format_test_data/031.golden: -------------------------------------------------------------------------------- 1 | deps += [ 2 | ":packed_extra_resources", 3 | ":packed_resources", 4 | 5 | # This shouldn't crash. 6 | 7 | # This shouldn't crash 2. 8 | ] 9 | -------------------------------------------------------------------------------- /src/gn/format_test_data/032.gn: -------------------------------------------------------------------------------- 1 | # Make sure continued conditions are aligned. 2 | if (something) { 3 | if (false) { 4 | } else if (is_linux && !is_android && current_cpu == "x64" && !disable_iterator_debugging) { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/gn/format_test_data/032.golden: -------------------------------------------------------------------------------- 1 | # Make sure continued conditions are aligned. 2 | if (something) { 3 | if (false) { 4 | } else if (is_linux && !is_android && current_cpu == "x64" && 5 | !disable_iterator_debugging) { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/gn/format_test_data/033.gn: -------------------------------------------------------------------------------- 1 | # Don't attach trailing comments too far back. 2 | if (!is_android) { 3 | source_set("tcmalloc") { 4 | if (is_win) { 5 | ldflags = [ "/ignore:4006:4221" ] 6 | } # is_win 7 | } # source_set 8 | } # !is_android 9 | -------------------------------------------------------------------------------- /src/gn/format_test_data/033.golden: -------------------------------------------------------------------------------- 1 | # Don't attach trailing comments too far back. 2 | if (!is_android) { 3 | source_set("tcmalloc") { 4 | if (is_win) { 5 | ldflags = [ "/ignore:4006:4221" ] 6 | } # is_win 7 | } # source_set 8 | } # !is_android 9 | -------------------------------------------------------------------------------- /src/gn/format_test_data/034.gn: -------------------------------------------------------------------------------- 1 | # Special case for 'args': If args[N] starts with '-' and args[N+1] is a call to 2 | # rebase_path, keep them as a pair, rather than breaking into individual items. 3 | action("wee") { 4 | if (something) { 5 | args = [ 6 | "--depfile", rebase_path(depfile, root_build_dir), 7 | "--android-sdk", rebase_path(android_sdk, root_build_dir), 8 | "--android-sdk-tools", 9 | rebase_path(android_sdk_build_tools, root_build_dir), 10 | "--android-manifest", rebase_path(android_manifest, root_build_dir), 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/gn/format_test_data/035.gn: -------------------------------------------------------------------------------- 1 | import("//build/config/sysroot.gni") # Imports android/config.gni. 2 | -------------------------------------------------------------------------------- /src/gn/format_test_data/035.golden: -------------------------------------------------------------------------------- 1 | import("//build/config/sysroot.gni") # Imports android/config.gni. 2 | -------------------------------------------------------------------------------- /src/gn/format_test_data/036.gn: -------------------------------------------------------------------------------- 1 | import("a") 2 | import("b") 3 | 4 | assert(x) 5 | assert(y) 6 | assert(z) 7 | 8 | source_set("stuff") { 9 | } 10 | -------------------------------------------------------------------------------- /src/gn/format_test_data/036.golden: -------------------------------------------------------------------------------- 1 | import("a") 2 | import("b") 3 | 4 | assert(x) 5 | assert(y) 6 | assert(z) 7 | 8 | source_set("stuff") { 9 | } 10 | -------------------------------------------------------------------------------- /src/gn/format_test_data/037.gn: -------------------------------------------------------------------------------- 1 | if (true) { 2 | if (true) { 3 | args = rebase_path(sources, root_build_dir) + rebase_path(outputs, root_build_dir) 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/gn/format_test_data/037.golden: -------------------------------------------------------------------------------- 1 | if (true) { 2 | if (true) { 3 | args = rebase_path(sources, root_build_dir) + 4 | rebase_path(outputs, root_build_dir) 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/gn/format_test_data/038.gn: -------------------------------------------------------------------------------- 1 | if (stuff) { 2 | # Blank line at EOF. 3 | } 4 | 5 | -------------------------------------------------------------------------------- /src/gn/format_test_data/038.golden: -------------------------------------------------------------------------------- 1 | if (stuff) { 2 | # Blank line at EOF. 3 | } 4 | -------------------------------------------------------------------------------- /src/gn/format_test_data/039.gn: -------------------------------------------------------------------------------- 1 | if (true) { 2 | assert(arm_float_abi == "" || 3 | arm_float_abi == "hard" || 4 | arm_float_abi == "soft" || 5 | arm_float_abi == "softfp") 6 | } 7 | -------------------------------------------------------------------------------- /src/gn/format_test_data/039.golden: -------------------------------------------------------------------------------- 1 | if (true) { 2 | assert(arm_float_abi == "" || arm_float_abi == "hard" || 3 | arm_float_abi == "soft" || arm_float_abi == "softfp") 4 | } 5 | -------------------------------------------------------------------------------- /src/gn/format_test_data/040.gn: -------------------------------------------------------------------------------- 1 | # Dewrapping shouldn't cause 80 col to be exceeded. 2 | # 80 --------------------------------------------------------------------------- 3 | if (true) { 4 | if (is_win) { 5 | cflags = [ 6 | "/wd4267", # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. 7 | ] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/gn/format_test_data/040.golden: -------------------------------------------------------------------------------- 1 | # Dewrapping shouldn't cause 80 col to be exceeded. 2 | # 80 --------------------------------------------------------------------------- 3 | if (true) { 4 | if (is_win) { 5 | cflags = [ 6 | "/wd4267", # TODO(jschuh): crbug.com/167187 fix size_t to int 7 | # truncations. 8 | ] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/gn/format_test_data/041.gn: -------------------------------------------------------------------------------- 1 | if (true) { 2 | a = [ "wee" ] 3 | 4 | b = [ 5 | "x", 6 | "y", 7 | "z", 8 | ] 9 | c = [ "x" ] 10 | 11 | d = [ "x" ] 12 | } 13 | -------------------------------------------------------------------------------- /src/gn/format_test_data/041.golden: -------------------------------------------------------------------------------- 1 | if (true) { 2 | a = [ "wee" ] 3 | 4 | b = [ 5 | "x", 6 | "y", 7 | "z", 8 | ] 9 | c = [ "x" ] 10 | 11 | d = [ "x" ] 12 | } 13 | -------------------------------------------------------------------------------- /src/gn/format_test_data/042.gn: -------------------------------------------------------------------------------- 1 | # Test zero, one, and multiple element for specifically named LHSs. 2 | if (true) { 3 | cflags = [] 4 | cflags_c = [] 5 | cflags_cc = [] 6 | data = [] 7 | datadeps = [] 8 | defines = [] 9 | deps = [] 10 | include_dirs = [] 11 | inputs = [] 12 | ldflags = [] 13 | outputs = [] 14 | public_deps = [] 15 | sources = [] 16 | } else if (true) { 17 | cflags = [ "x" ] 18 | cflags_c = [ "x" ] 19 | cflags_cc = [ "x" ] 20 | data = [ "x" ] 21 | datadeps = [ "x" ] 22 | defines = [ "x" ] 23 | deps = [ "x" ] 24 | include_dirs = [ "x" ] 25 | inputs = [ "x" ] 26 | ldflags = [ "x" ] 27 | outputs = [ "x" ] 28 | public_deps = [ "x" ] 29 | sources = [ "x" ] 30 | } else { 31 | cflags = [ "x", "y", "z"] 32 | cflags_c = [ "x", "y", "z"] 33 | cflags_cc = [ "x", "y", "z"] 34 | data = [ "x", "y", "z"] 35 | datadeps = [ "x", "y", "z"] 36 | defines = [ "x", "y", "z"] 37 | deps = [ "x", "y", "z"] 38 | include_dirs = [ "x", "y", "z"] 39 | inputs = [ "x", "y", "z"] 40 | ldflags = [ "x", "y", "z"] 41 | outputs = [ "x", "y", "z"] 42 | public_deps = [ "x", "y", "z"] 43 | sources = [ "x", "y", "z"] 44 | } 45 | -------------------------------------------------------------------------------- /src/gn/format_test_data/043.gn: -------------------------------------------------------------------------------- 1 | # Don't break and indent when it's hopeless. 2 | # 80 --------------------------------------------------------------------------- 3 | android_java_prebuilt("android_support_v13_java") { 4 | jar_path = "$android_sdk_root/extras/android/support/v7/appcompat/libs/android-support-v7-appcompat.jar" 5 | jar_path = "$android_sdk_root/extras/android/support/v13/android-support-v13.jar" 6 | } 7 | -------------------------------------------------------------------------------- /src/gn/format_test_data/043.golden: -------------------------------------------------------------------------------- 1 | # Don't break and indent when it's hopeless. 2 | # 80 --------------------------------------------------------------------------- 3 | android_java_prebuilt("android_support_v13_java") { 4 | jar_path = "$android_sdk_root/extras/android/support/v7/appcompat/libs/android-support-v7-appcompat.jar" 5 | jar_path = 6 | "$android_sdk_root/extras/android/support/v13/android-support-v13.jar" 7 | } 8 | -------------------------------------------------------------------------------- /src/gn/format_test_data/044.gn: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | config("compiler") { 3 | if (is_win) { 4 | if (is_component_build) { 5 | cflags += [ 6 | "/EHsc", # Assume C functions can't throw exceptions and don't catch 7 | # structured exceptions (only C++ ones). 8 | ] 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/gn/format_test_data/044.golden: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | config("compiler") { 3 | if (is_win) { 4 | if (is_component_build) { 5 | cflags += [ 6 | "/EHsc", # Assume C functions can't throw exceptions and don't catch 7 | # structured exceptions (only C++ ones). 8 | ] 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/gn/format_test_data/045.gn: -------------------------------------------------------------------------------- 1 | static_library("browser") { 2 | if (!is_ios) { 3 | sources += rebase_path(gypi_values.chrome_browser_predictor_sources, 4 | ".", "//chrome") 5 | sources += rebase_path(gypi_values.chrome_browser_predictor_sourcesaaaaaaaa, 6 | ".", "//chrome") 7 | sources += rebase_path(gypi_values.chrome_browser_predictor_sourcesaaaaaaaaa, 8 | ".", "//chrome") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/gn/format_test_data/045.golden: -------------------------------------------------------------------------------- 1 | static_library("browser") { 2 | if (!is_ios) { 3 | sources += rebase_path(gypi_values.chrome_browser_predictor_sources, 4 | ".", 5 | "//chrome") 6 | sources += rebase_path(gypi_values.chrome_browser_predictor_sourcesaaaaaaaa, 7 | ".", 8 | "//chrome") 9 | sources += 10 | rebase_path(gypi_values.chrome_browser_predictor_sourcesaaaaaaaaa, 11 | ".", 12 | "//chrome") 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/gn/format_test_data/046.gn: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | if (true) { 3 | # The JavaScript files required by main.html. 4 | remoting_webapp_main_html_js_files = 5 | # Include the core files first as it is required by the other files. 6 | # Otherwise, Jscompile will complain. 7 | remoting_webapp_js_core_files + 8 | remoting_webapp_js_auth_client2host_files + 9 | remoting_webapp_js_auth_google_files + 10 | remoting_webapp_js_client_files + 11 | remoting_webapp_js_gnubby_auth_files + 12 | remoting_webapp_js_cast_extension_files + 13 | remoting_webapp_js_host_files + 14 | remoting_webapp_js_logging_files + 15 | remoting_webapp_js_ui_files + 16 | remoting_webapp_js_ui_host_control_files + 17 | remoting_webapp_js_ui_host_display_files + 18 | remoting_webapp_js_wcs_container_files 19 | # Uncomment this line to include browser test files in the web app 20 | # to expedite debugging or local development. 21 | #+ remoting_webapp_js_browser_test_files 22 | } 23 | -------------------------------------------------------------------------------- /src/gn/format_test_data/046.golden: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | if (true) { 3 | # The JavaScript files required by main.html. 4 | remoting_webapp_main_html_js_files = 5 | # Include the core files first as it is required by the other files. 6 | # Otherwise, Jscompile will complain. 7 | remoting_webapp_js_core_files + 8 | remoting_webapp_js_auth_client2host_files + 9 | remoting_webapp_js_auth_google_files + remoting_webapp_js_client_files + 10 | remoting_webapp_js_gnubby_auth_files + 11 | remoting_webapp_js_cast_extension_files + remoting_webapp_js_host_files + 12 | remoting_webapp_js_logging_files + remoting_webapp_js_ui_files + 13 | remoting_webapp_js_ui_host_control_files + 14 | remoting_webapp_js_ui_host_display_files + 15 | remoting_webapp_js_wcs_container_files 16 | # Uncomment this line to include browser test files in the web app 17 | # to expedite debugging or local development. 18 | #+ remoting_webapp_js_browser_test_files 19 | } 20 | -------------------------------------------------------------------------------- /src/gn/format_test_data/047.gn: -------------------------------------------------------------------------------- 1 | if (true) { 2 | args += [ "--template" ] + 3 | rebase_path(remoting_webapp_template_files, template_rel_dir) 4 | args += [ "--dir-for-templates", 5 | rebase_path(template_rel_dir, root_build_dir) ] 6 | args += ["--js"] + rebase_path(remoting_webapp_main_html_js_files, template_rel_dir_and_some_more) 7 | } 8 | -------------------------------------------------------------------------------- /src/gn/format_test_data/047.golden: -------------------------------------------------------------------------------- 1 | if (true) { 2 | args += [ "--template" ] + 3 | rebase_path(remoting_webapp_template_files, template_rel_dir) 4 | args += [ 5 | "--dir-for-templates", 6 | rebase_path(template_rel_dir, root_build_dir), 7 | ] 8 | args += [ "--js" ] + rebase_path(remoting_webapp_main_html_js_files, 9 | template_rel_dir_and_some_more) 10 | } 11 | -------------------------------------------------------------------------------- /src/gn/format_test_data/048.gn: -------------------------------------------------------------------------------- 1 | # No blank inserted after libs (caused by trailing comment on 'else'). 2 | component("google_toolbox_for_mac") { 3 | if (!is_ios) { 4 | sources += [ 5 | "src/AddressBook/GTMABAddressBook.h", 6 | "src/AddressBook/GTMABAddressBook.m", 7 | ] 8 | 9 | frameworks = [ 10 | "AddressBook.framework", 11 | "AppKit.framework", 12 | ] 13 | } else { # is_ios 14 | sources += [ 15 | "src/iPhone/GTMFadeTruncatingLabel.h", 16 | "src/iPhone/GTMFadeTruncatingLabel.m", 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/gn/format_test_data/048.golden: -------------------------------------------------------------------------------- 1 | # No blank inserted after libs (caused by trailing comment on 'else'). 2 | component("google_toolbox_for_mac") { 3 | if (!is_ios) { 4 | sources += [ 5 | "src/AddressBook/GTMABAddressBook.h", 6 | "src/AddressBook/GTMABAddressBook.m", 7 | ] 8 | 9 | frameworks = [ 10 | "AddressBook.framework", 11 | "AppKit.framework", 12 | ] 13 | } else { # is_ios 14 | sources += [ 15 | "src/iPhone/GTMFadeTruncatingLabel.h", 16 | "src/iPhone/GTMFadeTruncatingLabel.m", 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/gn/format_test_data/049.gn: -------------------------------------------------------------------------------- 1 | func(aaaaaaaaaaaaaaaaaaaaa, 2 | bbbbbbbbbbbbbbbbbbbbbbbbbb, 3 | # Comment about function arg. 4 | ccccccccccccccccccccccccccccc, 5 | dddddddddddddddddddd) 6 | 7 | func(aaaaaaaaaaaaaaaaaaaaa, 8 | bbbbbbbbbbbbbbbbbbbbbbbbbb, 9 | 10 | # Block comment 11 | # Comment about function arg. 12 | 13 | ccccccccccccccccccccccccccccc, 14 | dddddddddddddddddddd) 15 | -------------------------------------------------------------------------------- /src/gn/format_test_data/050.gn: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | zippy = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb - cccccccccccccccccccccccc) 3 | 4 | zippy = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccccccccccc 5 | 6 | zippy = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccccccccccc + ddddddddddddddddddddd + eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + ffffffffffffff(aaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccc, ddddddddddddddddddd) 7 | 8 | zippy = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccccccccccc + ddddddddddddddddddddd + eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + ffffffffffffff(aaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbb + ccccccccccccccccccc + ddddddddddddddddddd) 9 | 10 | zippy = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccccccccccc + ddddddddddddddddddddd + eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + ffffffffffffff(aaaaaaaaaaaaa - (bbbbbbbbbbbbbbbbbbbbbbbb + ccccccccccccccccccc + ddddddddddddddddddd)) 11 | -------------------------------------------------------------------------------- /src/gn/format_test_data/050.golden: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | zippy = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - 3 | (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb - cccccccccccccccccccccccc) 4 | 5 | zippy = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + 6 | cccccccccccccccccccccccc 7 | 8 | zippy = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + 9 | cccccccccccccccccccccccc + ddddddddddddddddddddd + 10 | eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + 11 | ffffffffffffff(aaaaaaaaaaaaa, 12 | bbbbbbbbbbbbbbbbbbbbbbbb, 13 | ccccccccccccccccccc, 14 | ddddddddddddddddddd) 15 | 16 | zippy = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + 17 | cccccccccccccccccccccccc + ddddddddddddddddddddd + 18 | eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + 19 | ffffffffffffff(aaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbb + 20 | ccccccccccccccccccc + ddddddddddddddddddd) 21 | 22 | zippy = 23 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + 24 | cccccccccccccccccccccccc + ddddddddddddddddddddd + 25 | eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + 26 | ffffffffffffff(aaaaaaaaaaaaa - (bbbbbbbbbbbbbbbbbbbbbbbb + 27 | ccccccccccccccccccc + ddddddddddddddddddd)) 28 | -------------------------------------------------------------------------------- /src/gn/format_test_data/051.gn: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | if (true) { 3 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 4 | bbbbbbbbbbbbbbbbbbbb - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + 5 | cccccccccccccccccccccccccccccccccccc 6 | } 7 | -------------------------------------------------------------------------------- /src/gn/format_test_data/051.golden: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | if (true) { 3 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 4 | bbbbbbbbbbbbbbbbbbbb - 5 | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + 6 | cccccccccccccccccccccccccccccccccccc 7 | } 8 | -------------------------------------------------------------------------------- /src/gn/format_test_data/052.gn: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | if (true) { 3 | if (true) { 4 | sources += rebase_path( 5 | gypi_values.browser_chromeos_non_athena_sources, 6 | ".", "//chrome") + 7 | rebase_path(gypi_values.browser_chromeos_extension_non_athena_sources, 8 | ".", "//chrome") 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /src/gn/format_test_data/052.golden: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | if (true) { 3 | if (true) { 4 | sources += 5 | rebase_path(gypi_values.browser_chromeos_non_athena_sources, 6 | ".", 7 | "//chrome") + 8 | rebase_path(gypi_values.browser_chromeos_extension_non_athena_sources, 9 | ".", 10 | "//chrome") 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/gn/format_test_data/053.gn: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | if (true) { 3 | check_internal_result = exec_script( 4 | "build/check_internal.py", 5 | [ rebase_path("internal/google_chrome_api_keys.h", root_build_dir) ], 6 | "value") 7 | } 8 | -------------------------------------------------------------------------------- /src/gn/format_test_data/053.golden: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | if (true) { 3 | check_internal_result = 4 | exec_script("build/check_internal.py", 5 | [ rebase_path("internal/google_chrome_api_keys.h", 6 | root_build_dir) ], 7 | "value") 8 | } 9 | -------------------------------------------------------------------------------- /src/gn/format_test_data/054.gn: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | if (true) { 3 | args = [ 4 | "{{source}}", 5 | rebase_path("${target_gen_dir}/{{source_name_part}}-inc.cc", root_build_dir) 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /src/gn/format_test_data/054.golden: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | if (true) { 3 | args = [ 4 | "{{source}}", 5 | rebase_path("${target_gen_dir}/{{source_name_part}}-inc.cc", 6 | root_build_dir), 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /src/gn/format_test_data/055.gn: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | if (true) { 3 | if (true) { 4 | use_system_harfbuzz = exec_script( 5 | pkg_config_script, 6 | pkg_config_args + [ "--atleast-version=1.31.0", "pangoft2" ], 7 | "value") 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /src/gn/format_test_data/055.golden: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | if (true) { 3 | if (true) { 4 | use_system_harfbuzz = exec_script(pkg_config_script, 5 | pkg_config_args + [ 6 | "--atleast-version=1.31.0", 7 | "pangoft2", 8 | ], 9 | "value") 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/gn/format_test_data/056.gn: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | java_files = [ 3 | "test/android/java/src/org/chromium/base/ContentUriTestUtils.java" 4 | ] 5 | 6 | defines = [ 7 | "test/android/java/src/org/chromium/base/ContentUriTestUtils.java" 8 | ] 9 | 10 | defines = [ 11 | "abc/test/android/java/src/org/chromium/base/ContentUriTestUtils.java" 12 | ] 13 | 14 | cflags += [ 15 | # WEE 16 | "/a", 17 | "/b", 18 | "/c", 19 | ] 20 | 21 | sources = [ "/a", "/b", "/c" ] 22 | 23 | sources = [ 24 | # WEE 25 | "/a", 26 | "/b", 27 | "/c", 28 | ] 29 | 30 | sources += [ 31 | # WEE 32 | "/a", 33 | "/b", 34 | "/c", 35 | ] 36 | 37 | configs -= [ 38 | # Something! 39 | "//build/config/win:nominmax", 40 | ] 41 | 42 | cflags = [ 43 | "/wd4267", # size_t -> int 44 | "/wd4324", # structure was padded 45 | ] 46 | -------------------------------------------------------------------------------- /src/gn/format_test_data/056.golden: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | java_files = 3 | [ "test/android/java/src/org/chromium/base/ContentUriTestUtils.java" ] 4 | 5 | defines = [ "test/android/java/src/org/chromium/base/ContentUriTestUtils.java" ] 6 | 7 | defines = 8 | [ "abc/test/android/java/src/org/chromium/base/ContentUriTestUtils.java" ] 9 | 10 | cflags += [ 11 | # WEE 12 | "/a", 13 | "/b", 14 | "/c", 15 | ] 16 | 17 | sources = [ 18 | "/a", 19 | "/b", 20 | "/c", 21 | ] 22 | 23 | sources = [ 24 | # WEE 25 | "/a", 26 | "/b", 27 | "/c", 28 | ] 29 | 30 | sources += [ 31 | # WEE 32 | "/a", 33 | "/b", 34 | "/c", 35 | ] 36 | 37 | configs -= [ 38 | # Something! 39 | "//build/config/win:nominmax", 40 | ] 41 | 42 | cflags = [ 43 | "/wd4267", # size_t -> int 44 | "/wd4324", # structure was padded 45 | ] 46 | -------------------------------------------------------------------------------- /src/gn/format_test_data/057.gn: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | # Because there is a difference in precedence level between || and && 3 | # a || b || c && d 4 | # is equivalent to 5 | # a || b || (c && d) 6 | # Because parens are not stored in the parse tree, the formatter recreates the 7 | # minimally required set to maintain meaning. However, this particular case can 8 | # be confusing for human readers, so we special case these ones and add 9 | # strictly-unnecessary parens. 10 | 11 | supports_android = (is_apk || is_android_resources || 12 | (is_java_library && defined(invoker.supports_android) && 13 | invoker.supports_android)) 14 | 15 | enable_one_click_signin = is_win || is_mac || (is_linux && !is_chromeos) 16 | enable_one_click_signin = (is_linux && !is_chromeos) || is_win || is_mac 17 | 18 | x = c || (a&&b) 19 | x = (a&&b) || c 20 | x = a&&b || c 21 | 22 | x = c && (a||b) 23 | x = (a||b) && c 24 | x = a||b && c 25 | -------------------------------------------------------------------------------- /src/gn/format_test_data/057.golden: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | # Because there is a difference in precedence level between || and && 3 | # a || b || c && d 4 | # is equivalent to 5 | # a || b || (c && d) 6 | # Because parens are not stored in the parse tree, the formatter recreates the 7 | # minimally required set to maintain meaning. However, this particular case can 8 | # be confusing for human readers, so we special case these ones and add 9 | # strictly-unnecessary parens. 10 | 11 | supports_android = is_apk || is_android_resources || 12 | (is_java_library && defined(invoker.supports_android) && 13 | invoker.supports_android) 14 | 15 | enable_one_click_signin = is_win || is_mac || (is_linux && !is_chromeos) 16 | enable_one_click_signin = (is_linux && !is_chromeos) || is_win || is_mac 17 | 18 | x = c || (a && b) 19 | x = (a && b) || c 20 | x = (a && b) || c 21 | 22 | x = c && (a || b) 23 | x = (a || b) && c 24 | x = a || (b && c) 25 | -------------------------------------------------------------------------------- /src/gn/format_test_data/058.gn: -------------------------------------------------------------------------------- 1 | if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) { 2 | } 3 | -------------------------------------------------------------------------------- /src/gn/format_test_data/058.golden: -------------------------------------------------------------------------------- 1 | if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) { 2 | } 3 | -------------------------------------------------------------------------------- /src/gn/format_test_data/059.gn: -------------------------------------------------------------------------------- 1 | assert(type == "android_apk" || type == "java_library" || 2 | type == "android_resources" || things == stuff && stuff != 432) 3 | 4 | assert(type == "android_apk" || type == "java_library" || 5 | type == "android_resources", 6 | type == "android_apk" || type == "java_library" || 7 | type == "android_resources") 8 | 9 | 10 | if (type == "android_apk" || type == "java_library" || type == "android_resources" || things == stuff && stuff != 432) {} 11 | -------------------------------------------------------------------------------- /src/gn/format_test_data/059.golden: -------------------------------------------------------------------------------- 1 | assert(type == "android_apk" || type == "java_library" || 2 | type == "android_resources" || (things == stuff && stuff != 432)) 3 | 4 | assert(type == "android_apk" || type == "java_library" || 5 | type == "android_resources", 6 | type == "android_apk" || type == "java_library" || 7 | type == "android_resources") 8 | 9 | if (type == "android_apk" || type == "java_library" || 10 | type == "android_resources" || (things == stuff && stuff != 432)) { 11 | } 12 | -------------------------------------------------------------------------------- /src/gn/format_test_data/060.gn: -------------------------------------------------------------------------------- 1 | some_variable = "this is a very long string that is going to exceed 80 col and will never under any circumstance fit" 2 | another_variable = [ "this is a very long string that is going to exceed 80 col and will never under any circumstance fit" ] 3 | -------------------------------------------------------------------------------- /src/gn/format_test_data/060.golden: -------------------------------------------------------------------------------- 1 | some_variable = "this is a very long string that is going to exceed 80 col and will never under any circumstance fit" 2 | another_variable = [ "this is a very long string that is going to exceed 80 col and will never under any circumstance fit" ] 3 | -------------------------------------------------------------------------------- /src/gn/format_test_data/061.gn: -------------------------------------------------------------------------------- 1 | action("generate_gl_bindings") { 2 | args = [ 3 | "--header-paths=" + rebase_path("//third_party/khronos", root_build_dir) + 4 | ":" + rebase_path("//third_party/mesa/src/include", root_build_dir) + ":" + 5 | rebase_path("//ui/gl", root_build_dir) + ":" + 6 | rebase_path("//gpu", root_build_dir), 7 | rebase_path(gl_binding_output_dir, root_build_dir), 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /src/gn/format_test_data/061.golden: -------------------------------------------------------------------------------- 1 | action("generate_gl_bindings") { 2 | args = [ 3 | "--header-paths=" + rebase_path("//third_party/khronos", root_build_dir) + 4 | ":" + rebase_path("//third_party/mesa/src/include", root_build_dir) + 5 | ":" + rebase_path("//ui/gl", root_build_dir) + ":" + 6 | rebase_path("//gpu", root_build_dir), 7 | rebase_path(gl_binding_output_dir, root_build_dir), 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /src/gn/format_test_data/063.gn: -------------------------------------------------------------------------------- 1 | source_set("test") { 2 | a = "a" 3 | b = "b" 4 | deps = [ 5 | "//a", 6 | "//a/a", 7 | "//a/b", 8 | "//a:a", 9 | "//a:b", 10 | "//b", 11 | ":a", 12 | ":b", 13 | "a", 14 | "a/a", 15 | "a/b", 16 | "a:a", 17 | "a:b", 18 | "b", 19 | a, 20 | b, 21 | ] 22 | 23 | public_deps = [] 24 | if (condition) { 25 | public_deps += [ 26 | "//a", 27 | "//a/a", 28 | "//a:a", 29 | ":a", 30 | "a", 31 | "a/a", 32 | "a:a", 33 | a, 34 | ] 35 | } 36 | 37 | # Sort lists with "deps" suffix as "deps". 38 | foo_deps = [ 39 | "//a", 40 | ":z", 41 | ] 42 | 43 | # Likewise for visibility 44 | visibility = [ 45 | "//b:*", 46 | "//a", 47 | "//b/*", 48 | ":z", 49 | ] 50 | } 51 | -------------------------------------------------------------------------------- /src/gn/format_test_data/063.golden: -------------------------------------------------------------------------------- 1 | source_set("test") { 2 | a = "a" 3 | b = "b" 4 | deps = [ 5 | ":a", 6 | ":b", 7 | "a", 8 | "a:a", 9 | "a:b", 10 | "a/a", 11 | "a/b", 12 | "b", 13 | "//a", 14 | "//a:a", 15 | "//a:b", 16 | "//a/a", 17 | "//a/b", 18 | "//b", 19 | a, 20 | b, 21 | ] 22 | 23 | public_deps = [] 24 | if (condition) { 25 | public_deps += [ 26 | ":a", 27 | "a", 28 | "a:a", 29 | "a/a", 30 | "//a", 31 | "//a:a", 32 | "//a/a", 33 | a, 34 | ] 35 | } 36 | 37 | # Sort lists with "deps" suffix as "deps". 38 | foo_deps = [ 39 | ":z", 40 | "//a", 41 | ] 42 | 43 | # Likewise for visibility 44 | visibility = [ 45 | ":z", 46 | "//a", 47 | "//b:*", 48 | "//b/*", 49 | ] 50 | } 51 | -------------------------------------------------------------------------------- /src/gn/format_test_data/064.gn: -------------------------------------------------------------------------------- 1 | source_set("test") { 2 | deps = [ rebase_path(sdk_dep, ".", mojo_root) ] 3 | } 4 | -------------------------------------------------------------------------------- /src/gn/format_test_data/064.golden: -------------------------------------------------------------------------------- 1 | source_set("test") { 2 | deps = [ rebase_path(sdk_dep, ".", mojo_root) ] 3 | } 4 | -------------------------------------------------------------------------------- /src/gn/format_test_data/065.gn: -------------------------------------------------------------------------------- 1 | source_set("test") { 2 | some_target_name = ":some_target" 3 | deps = [ some_target_name, "//last_target", ":another_target" ] 4 | } 5 | -------------------------------------------------------------------------------- /src/gn/format_test_data/065.golden: -------------------------------------------------------------------------------- 1 | source_set("test") { 2 | some_target_name = ":some_target" 3 | deps = [ 4 | ":another_target", 5 | "//last_target", 6 | some_target_name, 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /src/gn/format_test_data/066.gn: -------------------------------------------------------------------------------- 1 | # Suppress sorting based on comment. 2 | 3 | # NOSORT 4 | sources = [] 5 | 6 | # NOSORT 7 | sources = [ 8 | "a", 9 | ] 10 | 11 | # NOSORT 12 | sources += [ 13 | "a", 14 | ] 15 | 16 | # NOSORT 17 | # This is NOSORT because reason. 18 | sources = [ 19 | "z", 20 | "z2", 21 | "a", 22 | "y.cc", 23 | ] 24 | 25 | # This is NOSORT because reason: 26 | # NOSORT 27 | sources += [ 28 | "z", 29 | "z2", 30 | "a", 31 | "y.cc", 32 | ] 33 | -------------------------------------------------------------------------------- /src/gn/format_test_data/066.golden: -------------------------------------------------------------------------------- 1 | # Suppress sorting based on comment. 2 | 3 | # NOSORT 4 | sources = [] 5 | 6 | # NOSORT 7 | sources = [ "a" ] 8 | 9 | # NOSORT 10 | sources += [ "a" ] 11 | 12 | # NOSORT 13 | # This is NOSORT because reason. 14 | sources = [ 15 | "z", 16 | "z2", 17 | "a", 18 | "y.cc", 19 | ] 20 | 21 | # This is NOSORT because reason: 22 | # NOSORT 23 | sources += [ 24 | "z", 25 | "z2", 26 | "a", 27 | "y.cc", 28 | ] 29 | -------------------------------------------------------------------------------- /src/gn/format_test_data/067.gn: -------------------------------------------------------------------------------- 1 | # Scope wrapping. 2 | 3 | myscope = { 4 | } 5 | myscope = { a = 1 } 6 | myscope = { a = 1 b = 2} 7 | # Comment 8 | SomeFunction({a=1}, "foo") 9 | -------------------------------------------------------------------------------- /src/gn/format_test_data/067.golden: -------------------------------------------------------------------------------- 1 | # Scope wrapping. 2 | 3 | myscope = { 4 | } 5 | myscope = { 6 | a = 1 7 | } 8 | myscope = { 9 | a = 1 10 | b = 2 11 | } 12 | 13 | # Comment 14 | SomeFunction({ 15 | a = 1 16 | }, 17 | "foo") 18 | -------------------------------------------------------------------------------- /src/gn/format_test_data/068.gn: -------------------------------------------------------------------------------- 1 | # Initial comment 2 | 3 | # Comment that should be separate, no subsequent content in file. 4 | -------------------------------------------------------------------------------- /src/gn/format_test_data/068.golden: -------------------------------------------------------------------------------- 1 | # Initial comment 2 | 3 | # Comment that should be separate, no subsequent content in file. 4 | -------------------------------------------------------------------------------- /src/gn/format_test_data/069.gn: -------------------------------------------------------------------------------- 1 | if (true) { 2 | configs -= [ "//third_party/mini_chromium/mini_chromium/build:Wexit_time_destructors", ] 3 | } 4 | -------------------------------------------------------------------------------- /src/gn/format_test_data/069.golden: -------------------------------------------------------------------------------- 1 | if (true) { 2 | configs -= [ 3 | "//third_party/mini_chromium/mini_chromium/build:Wexit_time_destructors", 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /src/gn/format_test_data/070.gn: -------------------------------------------------------------------------------- 1 | multiple = [ 2 | { 3 | name = "elements_test" 4 | }, 5 | { 6 | name = "eapol_crypto_test" 7 | }, 8 | ] 9 | 10 | 11 | single = [ 12 | { 13 | name = "elements_test" 14 | }, 15 | ] 16 | -------------------------------------------------------------------------------- /src/gn/format_test_data/070.golden: -------------------------------------------------------------------------------- 1 | multiple = [ 2 | { 3 | name = "elements_test" 4 | }, 5 | { 6 | name = "eapol_crypto_test" 7 | }, 8 | ] 9 | 10 | single = [ 11 | { 12 | name = "elements_test" 13 | }, 14 | ] 15 | -------------------------------------------------------------------------------- /src/gn/format_test_data/071.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("z.gni") 6 | import("x.gni") 7 | import("y.gni") 8 | 9 | import("b.gni") 10 | import("a.gni") 11 | 12 | 13 | 14 | import("m.gni") 15 | import("d1.gni") 16 | # Comment here 17 | import("c1.gni") 18 | 19 | import("../something/relative.gni") 20 | import("//build/stuff.gni") 21 | import("nopath.gni") 22 | import("//abc/things.gni") 23 | 24 | import("") 25 | import() 26 | import("a") 27 | -------------------------------------------------------------------------------- /src/gn/format_test_data/071.golden: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | import("x.gni") 6 | import("y.gni") 7 | import("z.gni") 8 | 9 | import("a.gni") 10 | import("b.gni") 11 | 12 | import("d1.gni") 13 | import("m.gni") 14 | 15 | # Comment here 16 | import("c1.gni") 17 | 18 | import("//abc/things.gni") 19 | import("//build/stuff.gni") 20 | import("../something/relative.gni") 21 | import("nopath.gni") 22 | 23 | import() 24 | import("") 25 | import("a") 26 | -------------------------------------------------------------------------------- /src/gn/format_test_data/072.gn: -------------------------------------------------------------------------------- 1 | import("b") import("c") import("a") import("d") 2 | 3 | import("z") declare_args() {} import("y") import("x") import("w") 4 | 5 | import("3") import("2") import("1") 6 | 7 | import("x") import("y") 8 | import("z") import("w") 9 | -------------------------------------------------------------------------------- /src/gn/format_test_data/072.golden: -------------------------------------------------------------------------------- 1 | import("a") 2 | import("b") 3 | import("c") 4 | import("d") 5 | 6 | import("z") 7 | declare_args() { 8 | } 9 | 10 | import("w") 11 | import("x") 12 | import("y") 13 | 14 | import("1") 15 | import("2") 16 | import("3") 17 | 18 | import("w") 19 | import("x") 20 | import("y") 21 | import("z") 22 | -------------------------------------------------------------------------------- /src/gn/format_test_data/073.gn: -------------------------------------------------------------------------------- 1 | import("//root/a") 2 | import("//root/c") 3 | import("//root/b") 4 | 5 | if (stuff) { 6 | import("3") import("2") import("1") 7 | if (things) { 8 | import("x") 9 | import("z") import("y") import("w") import("q") 10 | 11 | import("f") import("e") if (other) {import("z") import("a")} import("d") 12 | 13 | template("wee") { 14 | import("6") 15 | import("7") 16 | import("5") 17 | } 18 | } 19 | } else { 20 | import("i") 21 | import("h") 22 | import("g") 23 | } 24 | -------------------------------------------------------------------------------- /src/gn/format_test_data/073.golden: -------------------------------------------------------------------------------- 1 | import("//root/a") 2 | import("//root/b") 3 | import("//root/c") 4 | 5 | if (stuff) { 6 | import("1") 7 | import("2") 8 | import("3") 9 | if (things) { 10 | import("q") 11 | import("w") 12 | import("x") 13 | import("y") 14 | import("z") 15 | 16 | import("e") 17 | import("f") 18 | if (other) { 19 | import("a") 20 | import("z") 21 | } 22 | 23 | import("d") 24 | template("wee") { 25 | import("5") 26 | import("6") 27 | import("7") 28 | } 29 | } 30 | } else { 31 | import("g") 32 | import("h") 33 | import("i") 34 | } 35 | -------------------------------------------------------------------------------- /src/gn/format_test_data/074.gn: -------------------------------------------------------------------------------- 1 | config("something") { 2 | # Makes builds independent of absolute file path. 3 | if (symbol_level != 0 && is_clang && 4 | strip_absolute_paths_from_debug_symbols) { 5 | print("hi") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/gn/format_test_data/074.golden: -------------------------------------------------------------------------------- 1 | config("something") { 2 | # Makes builds independent of absolute file path. 3 | if (symbol_level != 0 && is_clang && 4 | strip_absolute_paths_from_debug_symbols) { 5 | print("hi") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/gn/format_test_data/075.gn: -------------------------------------------------------------------------------- 1 | # This tests for a case where formatting did not reach a fixed point after a 2 | # single run of formatting. 3 | 4 | import("stuff.gni") 5 | 6 | # Subprojects need to override arguments in {mac,ios}_sdk_overrides.gni in their 7 | # .gn config, but those arguments are only used on macOS. Including 8 | # mac_sdk_overrides.gni insures that this doesn't trigger an unused argument 9 | # warning. 10 | import("//build/config/mac/mac_sdk_overrides.gni") 11 | import("//build/config/ios/ios_sdk_overrides.gni") 12 | -------------------------------------------------------------------------------- /src/gn/format_test_data/075.golden: -------------------------------------------------------------------------------- 1 | # This tests for a case where formatting did not reach a fixed point after a 2 | # single run of formatting. 3 | 4 | import("stuff.gni") 5 | 6 | import("//build/config/ios/ios_sdk_overrides.gni") 7 | 8 | # Subprojects need to override arguments in {mac,ios}_sdk_overrides.gni in their 9 | # .gn config, but those arguments are only used on macOS. Including 10 | # mac_sdk_overrides.gni insures that this doesn't trigger an unused argument 11 | # warning. 12 | import("//build/config/mac/mac_sdk_overrides.gni") 13 | -------------------------------------------------------------------------------- /src/gn/format_test_data/076.gn: -------------------------------------------------------------------------------- 1 | # Intentionally contains tabs which the formatter should convert to spaces, but 2 | # only where it's not relevant to the parse. 3 | 4 | if (true) { 5 | sources = [ 6 | "a.c", "a.h", "main.c" 7 | ] 8 | } 9 | 10 | if (false) { 11 | embedded = "a tab to leave alone" 12 | } 13 | -------------------------------------------------------------------------------- /src/gn/format_test_data/076.golden: -------------------------------------------------------------------------------- 1 | # Intentionally contains tabs which the formatter should convert to spaces, but 2 | # only where it's not relevant to the parse. 3 | 4 | if (true) { 5 | sources = [ 6 | "a.c", 7 | "a.h", 8 | "main.c", 9 | ] 10 | } 11 | 12 | if (false) { 13 | embedded = "a tab to leave alone" 14 | } 15 | -------------------------------------------------------------------------------- /src/gn/format_test_data/077.gn: -------------------------------------------------------------------------------- 1 | # Regression test for https://crbug.com/gn/138. 80 col ------------------------- 2 | foo("bar") { 3 | blah = [ 4 | "$target_gen_dir/run-lit", # Non-existing, so that ninja runs it each time. 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /src/gn/format_test_data/077.golden: -------------------------------------------------------------------------------- 1 | # Regression test for https://crbug.com/gn/138. 80 col ------------------------- 2 | foo("bar") { 3 | blah = [ 4 | "$target_gen_dir/run-lit", # Non-existing, so that ninja runs it each time. 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /src/gn/format_test_data/078.gn: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | # Long suffix comments, and including trailing spaces. 3 | config("compiler") { 4 | if (is_win) { 5 | if (is_component_build) { 6 | cflags += [ 7 | "/EHsc", # These are some very long suffix comment words aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 8 | # bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 9 | # cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 10 | # dddddddddddddddd ddddddddddd dddddddd ddddddddddddd ddddddddddddddd 11 | ] 12 | } 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /src/gn/format_test_data/078.golden: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | # Long suffix comments, and including trailing spaces. 3 | config("compiler") { 4 | if (is_win) { 5 | if (is_component_build) { 6 | cflags += [ 7 | "/EHsc", # These are some very long suffix comment words 8 | # aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 9 | # bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 10 | # cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 11 | # dddddddddddddddd ddddddddddd dddddddd ddddddddddddd 12 | # ddddddddddddddd 13 | ] 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/gn/format_test_data/079.gn: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | # Somewhat more intelligent suffix comments. 3 | 4 | core_generated_interface_idl_files = generated_webcore_testing_idl_files # interfaces 5 | 6 | core_generated_interface_idl_files = generated_webcore_testing_idl_files_and_some_more_longer # stuff 7 | 8 | if (true) { 9 | if (true) { 10 | if (true) { 11 | dllname = "{{output_dir}}/{{target_output_name}}{{output_extension}}" # e.g. foo.dll 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/gn/format_test_data/079.golden: -------------------------------------------------------------------------------- 1 | # 80 --------------------------------------------------------------------------- 2 | # Somewhat more intelligent suffix comments. 3 | 4 | core_generated_interface_idl_files = 5 | generated_webcore_testing_idl_files # interfaces 6 | 7 | core_generated_interface_idl_files = 8 | generated_webcore_testing_idl_files_and_some_more_longer # stuff 9 | 10 | if (true) { 11 | if (true) { 12 | if (true) { 13 | dllname = 14 | "{{output_dir}}/{{target_output_name}}{{output_extension}}" # e.g. 15 | # foo.dll 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/gn/format_test_data/080.gn: -------------------------------------------------------------------------------- 1 | # https://crbug.com/gn/141. 80 col --------------------------------------------- 2 | 3 | a = 4 | [ "b" ] # comment1 5 | 6 | a = 7 | [ "b", "c" ] # comment1b 8 | 9 | a = 10 | b # comment2 11 | 12 | a = 13 | { b = 3 } # comment3 14 | 15 | a = 16 | { # comment4 17 | 18 | b = 3 } # comment5 19 | 20 | a = 21 | { b = 3 # comment6 22 | } 23 | 24 | if (true) { 25 | if (true) { 26 | if (true) { 27 | something_longer_on_the_lhs = 28 | [ "something that will exceed 80 col if dewrapped" ] # comment7 29 | 30 | something_longer_on_the_lhs = [ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ] # comment8 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/gn/format_test_data/080.golden: -------------------------------------------------------------------------------- 1 | # https://crbug.com/gn/141. 80 col --------------------------------------------- 2 | 3 | a = [ "b" ] # comment1 4 | 5 | a = [ 6 | "b", 7 | "c", 8 | ] # comment1b 9 | 10 | a = b # comment2 11 | 12 | a = { 13 | b = 3 14 | } # comment3 15 | 16 | a = { # comment4 17 | b = 3 18 | } # comment5 19 | 20 | a = { 21 | b = 3 # comment6 22 | } 23 | 24 | if (true) { 25 | if (true) { 26 | if (true) { 27 | something_longer_on_the_lhs = 28 | [ "something that will exceed 80 col if dewrapped" ] # comment7 29 | 30 | something_longer_on_the_lhs = 31 | [ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ] # comment8 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/gn/format_test_data/081.gn: -------------------------------------------------------------------------------- 1 | inputs = idl_lexer_parser_files + idl_compiler_files # to be explicit (covered by parsetab) 2 | inputs += "hi" 3 | 4 | if (true) { 5 | if (true) { 6 | inputs = idl_lexer_parser_files + idl_compiler_files # to be explicit (covered by parsetab) 7 | inputs += "hi" 8 | } 9 | } 10 | 11 | if (true) { 12 | if (something) { 13 | a = b 14 | } else { # !is_chromeos 15 | os_category = current_os 16 | } 17 | no_blank_here = true 18 | } 19 | -------------------------------------------------------------------------------- /src/gn/format_test_data/081.golden: -------------------------------------------------------------------------------- 1 | inputs = idl_lexer_parser_files + idl_compiler_files # to be explicit (covered 2 | # by parsetab) 3 | inputs += "hi" 4 | 5 | if (true) { 6 | if (true) { 7 | inputs = 8 | idl_lexer_parser_files + idl_compiler_files # to be explicit (covered 9 | # by parsetab) 10 | inputs += "hi" 11 | } 12 | } 13 | 14 | if (true) { 15 | if (something) { 16 | a = b 17 | } else { # !is_chromeos 18 | os_category = current_os 19 | } 20 | no_blank_here = true 21 | } 22 | -------------------------------------------------------------------------------- /src/gn/format_test_data/082.gn: -------------------------------------------------------------------------------- 1 | # https://crbug.com/gn/156 ----------------------------------------------------- 2 | if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && 3 | (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb || 4 | cccccccccccccccccccccc)) { 5 | } 6 | 7 | if (!is_nacl && !use_libfzzzzuzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzer && 8 | (target_os == "android" || target_os == "chromeos" || 9 | target_os == "fuchsia" || target_os == "linux" || 10 | target_os == "winnnnn")) { 11 | print("hi") 12 | } 13 | 14 | foo("bar") { 15 | if (foo) { 16 | if (!is_nacl && !use_libfuzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzer && 17 | (target_os == "android" || target_os == "chromeos" || 18 | target_os == "fuchsia" || target_os == "linux" || 19 | target_os == "win")) { 20 | cflags += [ "-Wunreachable-code" ] 21 | } 22 | } 23 | } 24 | 25 | foo("bar") { 26 | if (foo) { 27 | if (!is_nacl && !use_libfuzzer && 28 | (target_os == "android" || target_os == "chromeos" || 29 | target_os == "fuchsia" || target_os == "linux" || 30 | target_os == "win")) { 31 | cflags += [ "-Wunreachable-code" ] 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/gn/format_test_data/082.golden: -------------------------------------------------------------------------------- 1 | # https://crbug.com/gn/156 ----------------------------------------------------- 2 | if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && 3 | (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb || 4 | cccccccccccccccccccccc)) { 5 | } 6 | 7 | if (!is_nacl && !use_libfzzzzuzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzer && 8 | (target_os == "android" || target_os == "chromeos" || 9 | target_os == "fuchsia" || target_os == "linux" || 10 | target_os == "winnnnn")) { 11 | print("hi") 12 | } 13 | 14 | foo("bar") { 15 | if (foo) { 16 | if (!is_nacl && !use_libfuzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzer && 17 | (target_os == "android" || target_os == "chromeos" || 18 | target_os == "fuchsia" || target_os == "linux" || 19 | target_os == "win")) { 20 | cflags += [ "-Wunreachable-code" ] 21 | } 22 | } 23 | } 24 | 25 | foo("bar") { 26 | if (foo) { 27 | if (!is_nacl && !use_libfuzzer && 28 | (target_os == "android" || target_os == "chromeos" || 29 | target_os == "fuchsia" || target_os == "linux" || 30 | target_os == "win")) { 31 | cflags += [ "-Wunreachable-code" ] 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/gn/format_test_data/083.gn: -------------------------------------------------------------------------------- 1 | # Crash found by afl-fuzz (non-literal import). 2 | import("x") 3 | import(sources) 4 | import(zip) 5 | import(zap) 6 | import(a+b+c+d) 7 | import(zzz+yyy) 8 | -------------------------------------------------------------------------------- /src/gn/format_test_data/083.golden: -------------------------------------------------------------------------------- 1 | # Crash found by afl-fuzz (non-literal import). 2 | import(sources) 3 | import(zip) 4 | import(zap) 5 | import(a + b + c + d) 6 | import(zzz + yyy) 7 | import("x") 8 | -------------------------------------------------------------------------------- /src/gn/frameworks_utils.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/frameworks_utils.h" 6 | 7 | #include "gn/filesystem_utils.h" 8 | 9 | namespace { 10 | 11 | // Name of the extension of frameworks. 12 | const char kFrameworkExtension[] = "framework"; 13 | 14 | } // anonymous namespace 15 | 16 | std::string_view GetFrameworkName(const std::string& file) { 17 | if (FindFilenameOffset(file) != 0) 18 | return std::string_view(); 19 | 20 | std::string_view extension = FindExtension(&file); 21 | if (extension != kFrameworkExtension) 22 | return std::string_view(); 23 | 24 | return FindFilenameNoExtension(&file); 25 | } 26 | -------------------------------------------------------------------------------- /src/gn/frameworks_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_FRAMEWORKS_UTILS_H_ 6 | #define TOOLS_GN_FRAMEWORKS_UTILS_H_ 7 | 8 | #include 9 | #include 10 | 11 | // Returns the name of the framework from a file name. This returns an empty 12 | // string_view if the name is incorrect (does not ends in ".framework", ...). 13 | std::string_view GetFrameworkName(const std::string& file); 14 | 15 | #endif // TOOLS_GN_FRAMEWORKS_UTILS_H_ 16 | -------------------------------------------------------------------------------- /src/gn/frameworks_utils_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/frameworks_utils.h" 6 | 7 | #include "util/test/test.h" 8 | 9 | TEST(FrameworksUtils, GetFrameworkName) { 10 | const std::string kFramework = "Foundation.framework"; 11 | const std::string kFrameworkNoExtension = "Foundation"; 12 | const std::string kFrameworkPath = "Foo/Foo.framework"; 13 | 14 | EXPECT_EQ("Foundation", GetFrameworkName(kFramework)); 15 | EXPECT_EQ("", GetFrameworkName(kFrameworkNoExtension)); 16 | EXPECT_EQ("", GetFrameworkName(kFrameworkPath)); 17 | } 18 | -------------------------------------------------------------------------------- /src/gn/function_template_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/test_with_scope.h" 6 | #include "util/test/test.h" 7 | 8 | // Checks that variables used inside template definitions aren't reported 9 | // unused if they were declared above the template. 10 | TEST(FunctionTemplate, MarkUsed) { 11 | TestWithScope setup; 12 | TestParseInput input( 13 | "a = 1\n" // Unused outside of template. 14 | "template(\"templ\") {\n" 15 | " print(a)\n" 16 | "}\n"); 17 | ASSERT_FALSE(input.has_error()) << input.parse_err().message(); 18 | 19 | Err err; 20 | input.parsed()->Execute(setup.scope(), &err); 21 | ASSERT_FALSE(err.has_error()) << err.message(); 22 | 23 | // Normally the loader calls CheckForUnusedVars() when it loads a file 24 | // since normal blocks don't do this check. To avoid having to make this 25 | // test much more complicated, just explicitly do the check to make sure 26 | // things are marked properly. 27 | setup.scope()->CheckForUnusedVars(&err); 28 | EXPECT_FALSE(err.has_error()); 29 | } 30 | -------------------------------------------------------------------------------- /src/gn/general_tool.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_GENERAL_TOOL_H_ 6 | #define TOOLS_GN_GENERAL_TOOL_H_ 7 | 8 | #include 9 | 10 | #include "base/logging.h" 11 | #include "gn/label.h" 12 | #include "gn/label_ptr.h" 13 | #include "gn/substitution_list.h" 14 | #include "gn/substitution_pattern.h" 15 | #include "gn/tool.h" 16 | 17 | class GeneralTool : public Tool { 18 | public: 19 | // General tools 20 | static const char* kGeneralToolStamp; 21 | static const char* kGeneralToolCopy; 22 | static const char* kGeneralToolAction; 23 | 24 | // Platform-specific tools 25 | static const char* kGeneralToolCopyBundleData; 26 | static const char* kGeneralToolCompileXCAssets; 27 | 28 | GeneralTool(const char* n); 29 | ~GeneralTool(); 30 | 31 | // Manual RTTI and required functions --------------------------------------- 32 | 33 | bool InitTool(Scope* block_scope, Toolchain* toolchain, Err* err); 34 | bool ValidateName(const char* name) const override; 35 | void SetComplete() override; 36 | bool ValidateSubstitution(const Substitution* sub_type) const override; 37 | 38 | GeneralTool* AsGeneral() override; 39 | const GeneralTool* AsGeneral() const override; 40 | 41 | private: 42 | GeneralTool(const GeneralTool&) = delete; 43 | GeneralTool& operator=(const GeneralTool&) = delete; 44 | }; 45 | 46 | #endif // TOOLS_GN_GENERAL_TOOL_H_ 47 | -------------------------------------------------------------------------------- /src/gn/group_target_generator.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/group_target_generator.h" 6 | 7 | #include "gn/target.h" 8 | #include "gn/variables.h" 9 | 10 | GroupTargetGenerator::GroupTargetGenerator( 11 | Target* target, 12 | Scope* scope, 13 | const FunctionCallNode* function_call, 14 | Err* err) 15 | : TargetGenerator(target, scope, function_call, err) {} 16 | 17 | GroupTargetGenerator::~GroupTargetGenerator() = default; 18 | 19 | void GroupTargetGenerator::DoRun() { 20 | target_->set_output_type(Target::GROUP); 21 | // Groups only have the default types filled in by the target generator 22 | // base class. 23 | } 24 | -------------------------------------------------------------------------------- /src/gn/group_target_generator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_GROUP_TARGET_GENERATOR_H_ 6 | #define TOOLS_GN_GROUP_TARGET_GENERATOR_H_ 7 | 8 | #include "gn/target_generator.h" 9 | 10 | // Populates a Target with the values for a group rule. 11 | class GroupTargetGenerator : public TargetGenerator { 12 | public: 13 | GroupTargetGenerator(Target* target, 14 | Scope* scope, 15 | const FunctionCallNode* function_call, 16 | Err* err); 17 | ~GroupTargetGenerator() override; 18 | 19 | protected: 20 | void DoRun() override; 21 | 22 | private: 23 | GroupTargetGenerator(const GroupTargetGenerator&) = delete; 24 | GroupTargetGenerator& operator=(const GroupTargetGenerator&) = delete; 25 | }; 26 | 27 | #endif // TOOLS_GN_GROUP_TARGET_GENERATOR_H_ 28 | -------------------------------------------------------------------------------- /src/gn/input_conversion.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_INPUT_CONVERSION_H_ 6 | #define TOOLS_GN_INPUT_CONVERSION_H_ 7 | 8 | #include 9 | 10 | class Err; 11 | class ParseNode; 12 | class Settings; 13 | class Value; 14 | 15 | extern const char kInputOutputConversion_Help[]; 16 | 17 | // Converts the given input string (is read from a file or output from a 18 | // script) to a Value. Conversions as specified in the input_conversion string 19 | // will be performed. The given origin will be used for constructing the 20 | // resulting Value. 21 | // 22 | // If the conversion string is invalid, the error will be set and an empty 23 | // value will be returned. 24 | Value ConvertInputToValue(const Settings* settings, 25 | const std::string& input, 26 | const ParseNode* origin, 27 | const Value& input_conversion_value, 28 | Err* err); 29 | 30 | #endif // TOOLS_GN_INPUT_CONVERSION_H_ 31 | -------------------------------------------------------------------------------- /src/gn/input_file.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/input_file.h" 6 | 7 | #include "base/files/file_util.h" 8 | 9 | InputFile::InputFile(const SourceFile& name) 10 | : name_(name), dir_(name_.GetDir()) {} 11 | 12 | InputFile::~InputFile() = default; 13 | 14 | void InputFile::SetContents(const std::string& c) { 15 | contents_loaded_ = true; 16 | contents_ = c; 17 | } 18 | 19 | bool InputFile::Load(const base::FilePath& system_path) { 20 | if (base::ReadFileToString(system_path, &contents_)) { 21 | contents_loaded_ = true; 22 | physical_name_ = system_path; 23 | return true; 24 | } 25 | return false; 26 | } 27 | -------------------------------------------------------------------------------- /src/gn/json_project_writer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_JSON_WRITER_H_ 6 | #define TOOLS_GN_JSON_WRITER_H_ 7 | 8 | #include "gn/err.h" 9 | #include "gn/target.h" 10 | 11 | class Builder; 12 | class BuildSettings; 13 | class StringOutputBuffer; 14 | 15 | class JSONProjectWriter { 16 | public: 17 | static bool RunAndWriteFiles(const BuildSettings* build_setting, 18 | const Builder& builder, 19 | const std::string& file_name, 20 | const std::string& exec_script, 21 | const std::string& exec_script_extra_args, 22 | const std::string& dir_filter_string, 23 | bool quiet, 24 | Err* err); 25 | 26 | private: 27 | FRIEND_TEST_ALL_PREFIXES(JSONWriter, ActionWithResponseFile); 28 | FRIEND_TEST_ALL_PREFIXES(JSONWriter, ForEachWithResponseFile); 29 | FRIEND_TEST_ALL_PREFIXES(JSONWriter, RustTarget); 30 | 31 | static StringOutputBuffer GenerateJSON( 32 | const BuildSettings* build_settings, 33 | std::vector& all_targets); 34 | 35 | static std::string RenderJSON(const BuildSettings* build_settings, 36 | std::vector& all_targets); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/gn/jumbo_writer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef GN_JUMBO_WRITER_H_ 6 | #define GN_JUMBO_WRITER_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include "gn/path_output.h" 12 | #include "gn/target.h" 13 | 14 | // Helper class responsible for writing jumbo files. 15 | class JumboWriter { 16 | public: 17 | explicit JumboWriter(const Target* target); 18 | ~JumboWriter(); 19 | 20 | // Writes jumbo files for given |target|. 21 | static void RunAndWriteFiles(const Target* target); 22 | 23 | private: 24 | void Run() const; 25 | bool WriteJumboFile(const Target::JumboSourceFile& jumbo_file) const; 26 | 27 | const Target* target_; 28 | const PathOutput path_output_; 29 | 30 | JumboWriter(const JumboWriter&) = delete; 31 | JumboWriter& operator=(const JumboWriter&) = delete; 32 | }; 33 | 34 | #endif // GN_JUMBO_WRITER_H_ 35 | -------------------------------------------------------------------------------- /src/gn/lib_file.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/lib_file.h" 6 | 7 | #include "base/logging.h" 8 | 9 | LibFile::LibFile(const SourceFile& source_file) : source_file_(source_file) {} 10 | 11 | LibFile::LibFile(std::string_view lib_name) 12 | : name_(lib_name.data(), lib_name.size()) { 13 | DCHECK(!lib_name.empty()); 14 | } 15 | 16 | const std::string& LibFile::value() const { 17 | return is_source_file() ? source_file_.value() : name_; 18 | } 19 | 20 | const SourceFile& LibFile::source_file() const { 21 | DCHECK(is_source_file()); 22 | return source_file_; 23 | } 24 | -------------------------------------------------------------------------------- /src/gn/metadata_walk.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/metadata_walk.h" 6 | 7 | std::vector WalkMetadata( 8 | const UniqueVector& targets_to_walk, 9 | const std::vector& keys_to_extract, 10 | const std::vector& keys_to_walk, 11 | const SourceDir& rebase_dir, 12 | TargetSet* targets_walked, 13 | Err* err) { 14 | std::vector result; 15 | for (const auto* target : targets_to_walk) { 16 | if (targets_walked->add(target)) { 17 | if (!target->GetMetadata(keys_to_extract, keys_to_walk, rebase_dir, false, 18 | &result, targets_walked, err)) 19 | return std::vector(); 20 | } 21 | } 22 | return result; 23 | } 24 | -------------------------------------------------------------------------------- /src/gn/metadata_walk.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_METADATAWALK_H_ 6 | #define TOOLS_GN_METADATAWALK_H_ 7 | 8 | #include "gn/build_settings.h" 9 | #include "gn/target.h" 10 | #include "gn/unique_vector.h" 11 | #include "gn/value.h" 12 | 13 | // Function to collect metadata from resolved targets listed in targets_walked. 14 | // Intended to be called after all targets are resolved. 15 | // 16 | // This populates targets_walked with all targets touched by this walk, and 17 | // returns the list of metadata values. 18 | std::vector WalkMetadata( 19 | const UniqueVector& targets_to_walk, 20 | const std::vector& keys_to_extract, 21 | const std::vector& keys_to_walk, 22 | const SourceDir& rebase_dir, 23 | TargetSet* targets_walked, 24 | Err* err); 25 | 26 | #endif // TOOLS_GN_METADATAWALK_H_ 27 | -------------------------------------------------------------------------------- /src/gn/ninja_bundle_data_target_writer.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/ninja_bundle_data_target_writer.h" 6 | 7 | #include "gn/output_file.h" 8 | #include "gn/settings.h" 9 | #include "gn/target.h" 10 | 11 | NinjaBundleDataTargetWriter::NinjaBundleDataTargetWriter(const Target* target, 12 | std::ostream& out) 13 | : NinjaTargetWriter(target, out) {} 14 | 15 | NinjaBundleDataTargetWriter::~NinjaBundleDataTargetWriter() = default; 16 | 17 | void NinjaBundleDataTargetWriter::Run() { 18 | std::vector output_files; 19 | for (const SourceFile& source_file : target_->sources()) { 20 | output_files.push_back( 21 | OutputFile(settings_->build_settings(), source_file)); 22 | } 23 | 24 | std::vector input_deps = WriteInputDepsStampAndGetDep( 25 | std::vector(), /*num_stamp_uses=*/1); 26 | output_files.insert(output_files.end(), input_deps.begin(), input_deps.end()); 27 | 28 | std::vector order_only_deps; 29 | for (const auto& pair : target_->data_deps()) 30 | order_only_deps.push_back(pair.ptr->dependency_output_file()); 31 | 32 | WriteStampForTarget(output_files, order_only_deps); 33 | } 34 | -------------------------------------------------------------------------------- /src/gn/ninja_bundle_data_target_writer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_NINJA_BUNDLE_DATA_TARGET_WRITER_H_ 6 | #define TOOLS_GN_NINJA_BUNDLE_DATA_TARGET_WRITER_H_ 7 | 8 | #include "gn/ninja_target_writer.h" 9 | 10 | // Writes a .ninja file for a bundle_data target type. 11 | class NinjaBundleDataTargetWriter : public NinjaTargetWriter { 12 | public: 13 | NinjaBundleDataTargetWriter(const Target* target, std::ostream& out); 14 | ~NinjaBundleDataTargetWriter() override; 15 | 16 | void Run() override; 17 | 18 | private: 19 | NinjaBundleDataTargetWriter(const NinjaBundleDataTargetWriter&) = delete; 20 | NinjaBundleDataTargetWriter& operator=(const NinjaBundleDataTargetWriter&) = 21 | delete; 22 | }; 23 | 24 | #endif // TOOLS_GN_NINJA_BUNDLE_DATA_TARGET_WRITER_H_ 25 | -------------------------------------------------------------------------------- /src/gn/ninja_copy_target_writer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_NINJA_COPY_TARGET_WRITER_H_ 6 | #define TOOLS_GN_NINJA_COPY_TARGET_WRITER_H_ 7 | 8 | #include "gn/ninja_target_writer.h" 9 | 10 | // Writes a .ninja file for a copy target type. 11 | class NinjaCopyTargetWriter : public NinjaTargetWriter { 12 | public: 13 | NinjaCopyTargetWriter(const Target* target, std::ostream& out); 14 | ~NinjaCopyTargetWriter() override; 15 | 16 | void Run() override; 17 | 18 | private: 19 | // Writes the rules top copy the file(s), putting the computed output file 20 | // name(s) into the given vector. 21 | void WriteCopyRules(std::vector* output_files); 22 | 23 | NinjaCopyTargetWriter(const NinjaCopyTargetWriter&) = delete; 24 | NinjaCopyTargetWriter& operator=(const NinjaCopyTargetWriter&) = delete; 25 | }; 26 | 27 | #endif // TOOLS_GN_NINJA_COPY_TARGET_WRITER_H_ 28 | -------------------------------------------------------------------------------- /src/gn/ninja_generated_file_target_writer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_NINJA_GENERATED_FILE_TARGET_WRITER_H_ 6 | #define TOOLS_GN_NINJA_GENERATED_FILE_TARGET_WRITER_H_ 7 | 8 | #include "gn/ninja_target_writer.h" 9 | 10 | // Writes a .ninja file for a group target type. 11 | class NinjaGeneratedFileTargetWriter : public NinjaTargetWriter { 12 | public: 13 | NinjaGeneratedFileTargetWriter(const Target* target, std::ostream& out); 14 | ~NinjaGeneratedFileTargetWriter() override; 15 | 16 | void Run() override; 17 | 18 | private: 19 | void GenerateFile(); 20 | 21 | NinjaGeneratedFileTargetWriter(const NinjaGeneratedFileTargetWriter&) = 22 | delete; 23 | NinjaGeneratedFileTargetWriter& operator=( 24 | const NinjaGeneratedFileTargetWriter&) = delete; 25 | }; 26 | 27 | #endif // TOOLS_GN_NINJA_GENERATED_FILE_TARGET_WRITER_H_ 28 | -------------------------------------------------------------------------------- /src/gn/ninja_group_target_writer.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/ninja_group_target_writer.h" 6 | 7 | #include "base/strings/string_util.h" 8 | #include "gn/deps_iterator.h" 9 | #include "gn/output_file.h" 10 | #include "gn/string_utils.h" 11 | #include "gn/target.h" 12 | 13 | NinjaGroupTargetWriter::NinjaGroupTargetWriter(const Target* target, 14 | std::ostream& out) 15 | : NinjaTargetWriter(target, out) {} 16 | 17 | NinjaGroupTargetWriter::~NinjaGroupTargetWriter() = default; 18 | 19 | void NinjaGroupTargetWriter::Run() { 20 | // A group rule just generates a stamp file with dependencies on each of 21 | // the deps and data_deps in the group. 22 | std::vector output_files; 23 | std::vector data_output_files; 24 | for (const auto& pair : target_->GetDeps(Target::DEPS_LINKED)) { 25 | if (pair.ptr->IsDataOnly()) { 26 | data_output_files.push_back(pair.ptr->dependency_output_file()); 27 | } else { 28 | output_files.push_back(pair.ptr->dependency_output_file()); 29 | } 30 | } 31 | 32 | const LabelTargetVector& data_deps = target_->data_deps(); 33 | for (const auto& pair : data_deps) 34 | data_output_files.push_back(pair.ptr->dependency_output_file()); 35 | 36 | WriteStampForTarget(output_files, data_output_files); 37 | } 38 | -------------------------------------------------------------------------------- /src/gn/ninja_group_target_writer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_NINJA_GROUP_TARGET_WRITER_H_ 6 | #define TOOLS_GN_NINJA_GROUP_TARGET_WRITER_H_ 7 | 8 | #include "gn/ninja_target_writer.h" 9 | 10 | // Writes a .ninja file for a group target type. 11 | class NinjaGroupTargetWriter : public NinjaTargetWriter { 12 | public: 13 | NinjaGroupTargetWriter(const Target* target, std::ostream& out); 14 | ~NinjaGroupTargetWriter() override; 15 | 16 | void Run() override; 17 | 18 | private: 19 | NinjaGroupTargetWriter(const NinjaGroupTargetWriter&) = delete; 20 | NinjaGroupTargetWriter& operator=(const NinjaGroupTargetWriter&) = delete; 21 | }; 22 | 23 | #endif // TOOLS_GN_NINJA_GROUP_TARGET_WRITER_H_ 24 | -------------------------------------------------------------------------------- /src/gn/ninja_toolchain_writer_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include 6 | 7 | #include "gn/ninja_toolchain_writer.h" 8 | #include "gn/test_with_scope.h" 9 | #include "util/test/test.h" 10 | 11 | TEST(NinjaToolchainWriter, WriteToolRule) { 12 | TestWithScope setup; 13 | 14 | std::ostringstream stream; 15 | NinjaToolchainWriter writer(setup.settings(), setup.toolchain(), stream); 16 | writer.WriteToolRule(setup.toolchain()->GetTool(CTool::kCToolCc), 17 | std::string("prefix_")); 18 | 19 | EXPECT_EQ( 20 | "rule prefix_cc\n" 21 | " command = cc ${in} ${cflags} ${cflags_c} ${defines} ${include_dirs} " 22 | "-o ${out}\n", 23 | stream.str()); 24 | } 25 | 26 | TEST(NinjaToolchainWriter, WriteToolRuleWithLauncher) { 27 | TestWithScope setup; 28 | 29 | std::ostringstream stream; 30 | NinjaToolchainWriter writer(setup.settings(), setup.toolchain(), stream); 31 | writer.WriteToolRule(setup.toolchain()->GetTool(CTool::kCToolCxx), 32 | std::string("prefix_")); 33 | 34 | EXPECT_EQ( 35 | "rule prefix_cxx\n" 36 | " command = launcher c++ ${in} ${cflags} ${cflags_cc} ${defines} ${include_dirs} " 37 | "-o ${out}\n", 38 | stream.str()); 39 | } 40 | -------------------------------------------------------------------------------- /src/gn/ninja_utils.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/ninja_utils.h" 6 | 7 | #include "gn/filesystem_utils.h" 8 | #include "gn/settings.h" 9 | #include "gn/target.h" 10 | 11 | SourceFile GetNinjaFileForTarget(const Target* target) { 12 | return SourceFile( 13 | GetBuildDirForTargetAsSourceDir(target, BuildDirType::OBJ).value() + 14 | target->label().name() + ".ninja"); 15 | } 16 | 17 | SourceFile GetNinjaFileForToolchain(const Settings* settings) { 18 | return SourceFile(GetBuildDirAsSourceDir(BuildDirContext(settings), 19 | BuildDirType::TOOLCHAIN_ROOT) 20 | .value() + 21 | "toolchain.ninja"); 22 | } 23 | 24 | std::string GetNinjaRulePrefixForToolchain(const Settings* settings) { 25 | // Don't prefix the default toolchain so it looks prettier, prefix everything 26 | // else. 27 | if (settings->is_default()) 28 | return std::string(); // Default toolchain has no prefix. 29 | return settings->toolchain_label().name() + "_"; 30 | } 31 | -------------------------------------------------------------------------------- /src/gn/ninja_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_NINJA_UTILS_H_ 6 | #define TOOLS_GN_NINJA_UTILS_H_ 7 | 8 | #include 9 | 10 | class Settings; 11 | class SourceFile; 12 | class Target; 13 | 14 | // Example: "base/base.ninja". The string version will not be escaped, and 15 | // will always have slashes for path separators. 16 | SourceFile GetNinjaFileForTarget(const Target* target); 17 | 18 | // Returns the name of the root .ninja file for the given toolchain. 19 | SourceFile GetNinjaFileForToolchain(const Settings* settings); 20 | 21 | // Returns the prefix applied to the Ninja rules in a given toolchain so they 22 | // don't collide with rules from other toolchains. 23 | std::string GetNinjaRulePrefixForToolchain(const Settings* settings); 24 | 25 | #endif // TOOLS_GN_NINJA_UTILS_H_ 26 | -------------------------------------------------------------------------------- /src/gn/operators.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_OPERATORS_H_ 6 | #define TOOLS_GN_OPERATORS_H_ 7 | 8 | class BinaryOpNode; 9 | class Err; 10 | class ParseNode; 11 | class Scope; 12 | class UnaryOpNode; 13 | class Value; 14 | 15 | Value ExecuteUnaryOperator(Scope* scope, 16 | const UnaryOpNode* op_node, 17 | const Value& value, 18 | Err* err); 19 | Value ExecuteBinaryOperator(Scope* scope, 20 | const BinaryOpNode* op_node, 21 | const ParseNode* left, 22 | const ParseNode* right, 23 | Err* err); 24 | 25 | #endif // TOOLS_GN_OPERATORS_H_ 26 | -------------------------------------------------------------------------------- /src/gn/output_conversion.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_OUTPUT_CONVERSION_H_ 6 | #define TOOLS_GN_OUTPUT_CONVERSION_H_ 7 | 8 | #include 9 | #include 10 | 11 | class Err; 12 | class Settings; 13 | class Value; 14 | 15 | // Converts the given input Value to an output string (to be written to a file). 16 | // Conversions as specified in the output_conversion string will be performed. 17 | // The given ostream will be used for writing the resulting string. 18 | // 19 | // If the conversion string is invalid, the error will be set. 20 | void ConvertValueToOutput(const Settings* settings, 21 | const Value& output, 22 | const Value& output_conversion_value, 23 | std::ostream& out, 24 | Err* err); 25 | 26 | #endif // TOOLS_GN_OUTPUT_CONVERSION_H_ 27 | -------------------------------------------------------------------------------- /src/gn/output_file.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/output_file.h" 6 | 7 | #include "gn/filesystem_utils.h" 8 | #include "gn/source_file.h" 9 | 10 | OutputFile::OutputFile(std::string&& v) : value_(std::move(v)) {} 11 | 12 | OutputFile::OutputFile(const std::string& v) : value_(v) {} 13 | 14 | OutputFile::OutputFile(const BuildSettings* build_settings, 15 | const SourceFile& source_file) 16 | : value_(RebasePath(source_file.value(), 17 | build_settings->build_dir(), 18 | build_settings->root_path_utf8())) {} 19 | 20 | SourceFile OutputFile::AsSourceFile(const BuildSettings* build_settings) const { 21 | DCHECK(!value_.empty()); 22 | DCHECK(value_[value_.size() - 1] != '/'); 23 | 24 | std::string path = build_settings->build_dir().value(); 25 | path.append(value_); 26 | return SourceFile(std::move(path)); 27 | } 28 | 29 | SourceDir OutputFile::AsSourceDir(const BuildSettings* build_settings) const { 30 | if (!value_.empty()) { 31 | // Empty means the root build dir. Otherwise, we expect it to end in a 32 | // slash. 33 | DCHECK(value_[value_.size() - 1] == '/'); 34 | } 35 | std::string path = build_settings->build_dir().value(); 36 | path.append(value_); 37 | NormalizePath(&path); 38 | return SourceDir(std::move(path)); 39 | } 40 | -------------------------------------------------------------------------------- /src/gn/pool.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_POOL_H_ 6 | #define TOOLS_GN_POOL_H_ 7 | 8 | #include 9 | 10 | #include "gn/item.h" 11 | 12 | // Represents a named pool in the dependency graph. 13 | // 14 | // A pool is used to limit the parallelism of task invocation in the 15 | // generated ninja build. Pools are referenced by toolchains. 16 | class Pool : public Item { 17 | public: 18 | using Item::Item; 19 | ~Pool() override; 20 | 21 | // Item implementation. 22 | Pool* AsPool() override; 23 | const Pool* AsPool() const override; 24 | 25 | // The pool depth (number of task to run simultaneously). 26 | int64_t depth() const { return depth_; } 27 | void set_depth(int64_t depth) { depth_ = depth; } 28 | 29 | // The pool name in generated ninja files. 30 | std::string GetNinjaName(const Label& default_toolchain) const; 31 | 32 | private: 33 | std::string GetNinjaName(bool include_toolchain) const; 34 | 35 | int64_t depth_ = 0; 36 | 37 | Pool(const Pool&) = delete; 38 | Pool& operator=(const Pool&) = delete; 39 | }; 40 | 41 | #endif // TOOLS_GN_POOL_H_ 42 | -------------------------------------------------------------------------------- /src/gn/runtime_deps.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_RUNTIME_DEPS_H 6 | #define TOOLS_GN_RUNTIME_DEPS_H 7 | 8 | #include 9 | #include 10 | 11 | class Builder; 12 | class BuildSettings; 13 | class Err; 14 | class OutputFile; 15 | class Target; 16 | 17 | extern const char kRuntimeDeps_Help[]; 18 | 19 | // Computes the runtime dependencies of the given target. The result is a list 20 | // of pairs listing the runtime dependency and the target that the runtime 21 | // dependency is from (for blaming). 22 | std::vector> ComputeRuntimeDeps( 23 | const Target* target); 24 | 25 | // Writes all runtime deps files requested on the command line, or does nothing 26 | // if no files were specified. 27 | bool WriteRuntimeDepsFilesIfNecessary(const BuildSettings* build_settings, 28 | const Builder& builder, 29 | Err* err); 30 | 31 | #endif // TOOLS_GN_RUNTIME_DEPS_H 32 | -------------------------------------------------------------------------------- /src/gn/rust_project_writer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_RUST_PROJECT_WRITER_H_ 6 | #define TOOLS_GN_RUST_PROJECT_WRITER_H_ 7 | 8 | #include "gn/err.h" 9 | #include "gn/target.h" 10 | 11 | class Builder; 12 | class BuildSettings; 13 | 14 | // rust-project.json is an output format describing the rust build graph. It is 15 | // used by rust-analyzer (a LSP server), similar to compile-commands.json. 16 | // 17 | // an example output is in rust_project_writer.cc 18 | class RustProjectWriter { 19 | public: 20 | // Write Rust build graph into a json file located by parameter file_name. 21 | // 22 | // Parameter quiet is not used. 23 | static bool RunAndWriteFiles(const BuildSettings* build_setting, 24 | const Builder& builder, 25 | const std::string& file_name, 26 | bool quiet, 27 | Err* err); 28 | static void RenderJSON(const BuildSettings* build_settings, 29 | std::vector& all_targets, 30 | std::ostream& rust_project); 31 | 32 | private: 33 | // This function visits the deps graph of a target in a DFS fashion. 34 | static void VisitDeps(const Target* target, TargetSet* visited); 35 | }; 36 | 37 | #endif // TOOLS_GN_RUST_PROJECT_WRITER_H_ 38 | -------------------------------------------------------------------------------- /src/gn/rust_substitution_type.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_RUST_SUBSTITUTION_TYPE_H_ 6 | #define TOOLS_GN_RUST_SUBSTITUTION_TYPE_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include "gn/substitution_type.h" 12 | 13 | // The set of substitutions available to Rust tools. 14 | extern const SubstitutionTypes RustSubstitutions; 15 | 16 | // Valid for Rust tools. 17 | extern const Substitution kRustSubstitutionCrateName; 18 | extern const Substitution kRustSubstitutionCrateType; 19 | extern const Substitution kRustSubstitutionExterns; 20 | extern const Substitution kRustSubstitutionRustDeps; 21 | extern const Substitution kRustSubstitutionRustEnv; 22 | extern const Substitution kRustSubstitutionRustFlags; 23 | extern const Substitution kRustSubstitutionSources; 24 | 25 | bool IsValidRustSubstitution(const Substitution* type); 26 | bool IsValidRustLinkerSubstitution(const Substitution* type); 27 | 28 | #endif // TOOLS_GN_RUST_SUBSTITUTION_TYPE_H_ 29 | -------------------------------------------------------------------------------- /src/gn/rust_values_generator.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_RUST_VALUES_GENERATOR_H_ 6 | #define TOOLS_GN_RUST_VALUES_GENERATOR_H_ 7 | 8 | #include "gn/target.h" 9 | 10 | class FunctionCallNode; 11 | 12 | // Collects and writes specified data. 13 | class RustValuesGenerator { 14 | public: 15 | RustValuesGenerator(Target* target, 16 | Scope* scope, 17 | const FunctionCallNode* function_call, 18 | Err* err); 19 | ~RustValuesGenerator(); 20 | 21 | void Run(); 22 | 23 | private: 24 | bool FillCrateName(); 25 | bool FillCrateRoot(); 26 | bool FillCrateType(); 27 | bool FillEdition(); 28 | bool FillAliasedDeps(); 29 | 30 | Target* target_; 31 | Scope* scope_; 32 | const FunctionCallNode* function_call_; 33 | Err* err_; 34 | 35 | RustValuesGenerator(const RustValuesGenerator&) = delete; 36 | RustValuesGenerator& operator=(const RustValuesGenerator&) = delete; 37 | }; 38 | 39 | #endif // TOOLS_GN_RUST_VALUES_GENERATOR_H_ 40 | -------------------------------------------------------------------------------- /src/gn/rust_variables.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_RUST_VARIABLES_H_ 6 | #define TOOLS_GN_RUST_VARIABLES_H_ 7 | 8 | #include "gn/variables.h" 9 | 10 | namespace variables { 11 | 12 | // Rust target vars ------------------------------------------------------ 13 | 14 | extern const char kRustAliasedDeps[]; 15 | extern const char kRustAliasedDeps_HelpShort[]; 16 | extern const char kRustAliasedDeps_Help[]; 17 | 18 | extern const char kRustCrateName[]; 19 | extern const char kRustCrateName_HelpShort[]; 20 | extern const char kRustCrateName_Help[]; 21 | 22 | extern const char kRustCrateType[]; 23 | extern const char kRustCrateType_HelpShort[]; 24 | extern const char kRustCrateType_Help[]; 25 | 26 | extern const char kRustCrateRoot[]; 27 | extern const char kRustCrateRoot_HelpShort[]; 28 | extern const char kRustCrateRoot_Help[]; 29 | 30 | extern const char kRustEdition[]; 31 | extern const char kRustEdition_HelpShort[]; 32 | extern const char kRustEdition_Help[]; 33 | 34 | void InsertRustVariables(VariableInfoMap* info_map); 35 | 36 | } // namespace variables 37 | 38 | #endif // TOOLS_GN_RUST_VARIABLES_H_ -------------------------------------------------------------------------------- /src/gn/settings.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/settings.h" 6 | 7 | #include "base/logging.h" 8 | #include "gn/filesystem_utils.h" 9 | #include "util/build_config.h" 10 | 11 | Settings::Settings(const BuildSettings* build_settings, 12 | const std::string& output_subdir_name) 13 | : build_settings_(build_settings), base_config_(this) { 14 | if (output_subdir_name.empty()) { 15 | toolchain_output_dir_ = build_settings->build_dir(); 16 | } else { 17 | // We guarantee this ends in a slash. 18 | DCHECK(output_subdir_name[output_subdir_name.size() - 1] == '/'); 19 | toolchain_output_subdir_.value().append(output_subdir_name); 20 | 21 | DCHECK(!build_settings->build_dir().is_null()); 22 | toolchain_output_dir_ = SourceDir(build_settings->build_dir().value() + 23 | toolchain_output_subdir_.value()); 24 | } 25 | // The output dir will be null in some tests and when invoked to parsed 26 | // one-off data without doing generation. 27 | if (!toolchain_output_dir_.is_null()) 28 | toolchain_gen_dir_ = SourceDir(toolchain_output_dir_.value() + "gen/"); 29 | } 30 | -------------------------------------------------------------------------------- /src/gn/swift_values_generator.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_SWIFT_TARGET_VALUES_GENERATOR_H_ 6 | #define TOOLS_GN_SWIFT_TARGET_VALUES_GENERATOR_H_ 7 | 8 | #include 9 | 10 | class Err; 11 | class FunctionCallNode; 12 | class Scope; 13 | class Target; 14 | 15 | class SwiftValuesGenerator { 16 | public: 17 | SwiftValuesGenerator(Target* target, Scope* scope, Err* err); 18 | ~SwiftValuesGenerator(); 19 | 20 | SwiftValuesGenerator(const SwiftValuesGenerator&) = delete; 21 | SwiftValuesGenerator& operator=(const SwiftValuesGenerator&) = delete; 22 | 23 | void Run(); 24 | 25 | private: 26 | bool FillBridgeHeader(); 27 | bool FillModuleName(); 28 | 29 | Target* target_; 30 | Scope* scope_; 31 | Err* err_; 32 | }; 33 | 34 | #endif // TOOLS_GN_SWIFT_TARGET_VALUES_GENERATOR_H_ 35 | -------------------------------------------------------------------------------- /src/gn/swift_variables.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_SWIFT_TARGET_VARIABLES_H_ 6 | #define TOOLS_GN_SWIFT_TARGET_VARIABLES_H_ 7 | 8 | #include "gn/variables.h" 9 | 10 | namespace variables { 11 | 12 | // Swift target vars ----------------------------------------------------- 13 | 14 | extern const char kSwiftBridgeHeader[]; 15 | extern const char kSwiftBridgeHeader_HelpShort[]; 16 | extern const char kSwiftBridgeHeader_Help[]; 17 | 18 | extern const char kSwiftModuleName[]; 19 | extern const char kSwiftModuleName_HelpShort[]; 20 | extern const char kSwiftModuleName_Help[]; 21 | 22 | void InsertSwiftVariables(VariableInfoMap* info_map); 23 | 24 | } // namespace variables 25 | 26 | #endif // TOOLS_GN_SWIFT_TARGET_VARIABLES_H_ 27 | -------------------------------------------------------------------------------- /src/gn/test_with_scheduler.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/test_with_scheduler.h" 6 | 7 | TestWithScheduler::TestWithScheduler() = default; 8 | TestWithScheduler::~TestWithScheduler() = default; 9 | -------------------------------------------------------------------------------- /src/gn/test_with_scheduler.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_TEST_WITH_SCHEDULER_H_ 6 | #define TOOLS_GN_TEST_WITH_SCHEDULER_H_ 7 | 8 | #include "gn/scheduler.h" 9 | #include "util/msg_loop.h" 10 | #include "util/test/test.h" 11 | 12 | class TestWithScheduler : public testing::Test { 13 | protected: 14 | TestWithScheduler(); 15 | ~TestWithScheduler() override; 16 | 17 | Scheduler& scheduler() { return scheduler_; } 18 | 19 | private: 20 | MsgLoop run_loop_; 21 | Scheduler scheduler_; 22 | 23 | TestWithScheduler(const TestWithScheduler&) = delete; 24 | TestWithScheduler& operator=(const TestWithScheduler&) = delete; 25 | }; 26 | 27 | #endif // TOOLS_GN_TEST_WITH_SCHEDULER_H_ 28 | -------------------------------------------------------------------------------- /src/gn/token.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/token.h" 6 | 7 | #include "base/logging.h" 8 | #include "gn/tokenizer.h" 9 | 10 | Token::Token() : type_(INVALID), value_() {} 11 | 12 | Token::Token(const Location& location, Type t, std::string_view v) 13 | : type_(t), value_(v), location_(location) {} 14 | 15 | // static 16 | Token Token::ClassifyAndMake(const Location& location, std::string_view v) { 17 | char first = v.size() > 0 ? v[0] : '\0'; 18 | char second = v.size() > 1 ? v[1] : '\0'; 19 | return Token(location, Tokenizer::ClassifyToken(first, second), v); 20 | } 21 | 22 | bool Token::IsIdentifierEqualTo(const char* v) const { 23 | return type_ == IDENTIFIER && value_ == v; 24 | } 25 | 26 | bool Token::IsStringEqualTo(const char* v) const { 27 | return type_ == STRING && value_ == v; 28 | } 29 | -------------------------------------------------------------------------------- /src/gn/version.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef TOOLS_GN_VERSION_H_ 6 | #define TOOLS_GN_VERSION_H_ 7 | 8 | #include 9 | #include 10 | 11 | #ifdef major 12 | #undef major 13 | #endif 14 | #ifdef minor 15 | #undef minor 16 | #endif 17 | 18 | // Represents a semantic version. 19 | class Version { 20 | public: 21 | Version(int major, int minor, int patch); 22 | 23 | static std::optional FromString(std::string s); 24 | 25 | int major() const { return major_; } 26 | int minor() const { return minor_; } 27 | int patch() const { return patch_; } 28 | 29 | bool operator==(const Version& other) const; 30 | bool operator<(const Version& other) const; 31 | bool operator!=(const Version& other) const; 32 | bool operator>=(const Version& other) const; 33 | bool operator>(const Version& other) const; 34 | bool operator<=(const Version& other) const; 35 | 36 | std::string Describe() const; 37 | 38 | private: 39 | int major_; 40 | int minor_; 41 | int patch_; 42 | }; 43 | 44 | #endif // TOOLS_GN_VERSION_H_ 45 | -------------------------------------------------------------------------------- /src/gn/version_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "gn/version.h" 6 | 7 | #include "util/test/test.h" 8 | 9 | TEST(VersionTest, FromString) { 10 | Version v0_0_1{0, 0, 1}; 11 | ASSERT_EQ(Version::FromString("0.0.1"), v0_0_1); 12 | Version v0_1_0{0, 1, 0}; 13 | ASSERT_EQ(Version::FromString("0.1.0"), v0_1_0); 14 | Version v1_0_0{1, 0, 0}; 15 | ASSERT_EQ(Version::FromString("1.0.0"), v1_0_0); 16 | } 17 | 18 | TEST(VersionTest, Comparison) { 19 | Version v0_0_1{0, 0, 1}; 20 | Version v0_1_0{0, 1, 0}; 21 | ASSERT_TRUE(v0_0_1 == v0_0_1); 22 | ASSERT_TRUE(v0_0_1 != v0_1_0); 23 | ASSERT_TRUE(v0_0_1 <= v0_0_1); 24 | ASSERT_TRUE(v0_0_1 <= v0_1_0); 25 | ASSERT_TRUE(v0_0_1 < v0_1_0); 26 | ASSERT_TRUE(v0_0_1 >= v0_0_1); 27 | ASSERT_TRUE(v0_1_0 > v0_0_1); 28 | ASSERT_TRUE(v0_1_0 >= v0_0_1); 29 | } 30 | 31 | TEST(VersionTest, Describe) { 32 | ASSERT_EQ(Version::FromString("0.0.1")->Describe(), "0.0.1"); 33 | } 34 | -------------------------------------------------------------------------------- /src/util/exe_path.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef UTIL_EXE_PATH_H_ 6 | #define UTIL_EXE_PATH_H_ 7 | 8 | #include "base/files/file_path.h" 9 | 10 | base::FilePath GetExePath(); 11 | 12 | #endif // UTIL_EXE_PATH_H_ 13 | -------------------------------------------------------------------------------- /src/util/msg_loop.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef UTIL_RUN_LOOP_H_ 6 | #define UTIL_RUN_LOOP_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | class MsgLoop { 14 | public: 15 | MsgLoop(); 16 | ~MsgLoop(); 17 | 18 | // Blocks until PostQuit() is called, processing work items posted via 19 | void Run(); 20 | 21 | // Schedules Run() to exit, but will not happen until other outstanding tasks 22 | // complete. Can be called from any thread. 23 | void PostQuit(); 24 | 25 | // Posts a work item to this queue. All items will be run on the thread from 26 | // which Run() was called. Can be called from any thread. 27 | void PostTask(std::function task); 28 | 29 | // Run()s until the queue is empty. Should only be used (carefully) in tests. 30 | void RunUntilIdleForTesting(); 31 | 32 | // Gets the MsgLoop for the thread from which it's called, or nullptr if 33 | // there's no MsgLoop for the current thread. 34 | static MsgLoop* Current(); 35 | 36 | private: 37 | std::mutex queue_mutex_; 38 | std::queue> task_queue_; 39 | std::condition_variable notifier_; 40 | bool should_quit_ = false; 41 | 42 | MsgLoop(const MsgLoop&) = delete; 43 | MsgLoop& operator=(const MsgLoop&) = delete; 44 | }; 45 | 46 | #endif // UTIL_RUN_LOOP_H_ 47 | -------------------------------------------------------------------------------- /src/util/sys_info.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef UTIL_SYS_INFO_H_ 6 | #define UTIL_SYS_INFO_H_ 7 | 8 | #include 9 | 10 | std::string OperatingSystemArchitecture(); 11 | int NumberOfProcessors(); 12 | 13 | #endif // UTIL_SYS_INFO_H_ 14 | -------------------------------------------------------------------------------- /src/util/ticks.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef UTIL_TICKS_H_ 6 | #define UTIL_TICKS_H_ 7 | 8 | #include 9 | 10 | using Ticks = uint64_t; 11 | 12 | class TickDelta { 13 | public: 14 | explicit TickDelta(uint64_t delta) : delta_(delta) {} 15 | 16 | double InSecondsF() const { return delta_ / 1000000000.0; } 17 | double InMillisecondsF() const { return delta_ / 1000000.0; } 18 | double InMicrosecondsF() const { return delta_ / 1000.0; } 19 | double InNanosecondsF() const { return delta_; } 20 | 21 | uint64_t InSeconds() const { return delta_ / 1000000000; } 22 | uint64_t InMilliseconds() const { return delta_ / 1000000; } 23 | uint64_t InMicroseconds() const { return delta_ / 1000; } 24 | uint64_t InNanoseconds() const { return delta_; } 25 | 26 | uint64_t raw() const { return delta_; } 27 | 28 | private: 29 | uint64_t delta_; 30 | }; 31 | 32 | Ticks TicksNow(); 33 | 34 | TickDelta TicksDelta(Ticks new_ticks, Ticks old_ticks); 35 | 36 | class ElapsedTimer { 37 | public: 38 | ElapsedTimer() : start_(TicksNow()) {} 39 | TickDelta Elapsed() { return TicksDelta(TicksNow(), start_); } 40 | 41 | private: 42 | Ticks start_; 43 | }; 44 | 45 | #endif // UTIL_TICKS_H_ 46 | -------------------------------------------------------------------------------- /src/util/worker_pool.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef UTIL_WORKER_POOL_H_ 6 | #define UTIL_WORKER_POOL_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "base/logging.h" 15 | 16 | class WorkerPool { 17 | public: 18 | WorkerPool(); 19 | WorkerPool(size_t thread_count); 20 | ~WorkerPool(); 21 | 22 | void PostTask(std::function work); 23 | 24 | private: 25 | void Worker(); 26 | 27 | std::vector threads_; 28 | std::queue> task_queue_; 29 | std::mutex queue_mutex_; 30 | std::condition_variable_any pool_notifier_; 31 | bool should_stop_processing_; 32 | 33 | WorkerPool(const WorkerPool&) = delete; 34 | WorkerPool& operator=(const WorkerPool&) = delete; 35 | }; 36 | 37 | #endif // UTIL_WORKER_POOL_H_ 38 | --------------------------------------------------------------------------------