1# Copyright 2021 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5# Defines a template for Swift source files. The default module_name 6# of the target is the entire target label (without the leading //) 7# with all "/" and ":" replaced with "_". 8template("swift_source_set") { 9 _target_name = target_name 10 source_set(target_name) { 11 forward_variables_from(invoker, "*", TESTONLY_AND_VISIBILITY) 12 forward_variables_from(invoker, TESTONLY_AND_VISIBILITY) 13 if (!defined(module_name)) { 14 _target_label = get_label_info(":$_target_name", "label_no_toolchain") 15 16 # Strip the // from the beginning of the label. 17 _target_label = string_replace(_target_label, "//", "", 1) 18 module_name = 19 string_replace(string_replace(_target_label, "/", "_"), ":", "_") 20 } 21 } 22} 23set_defaults("swift_source_set") { 24 configs = default_compiler_configs 25} 26