1# Copyright 2022 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pw_build/target_types.gni") 18 19group("basic_executable") { 20 if (pw_rust_USE_STD) { 21 deps = [ 22 ":hello", 23 ":hello_pw_log", 24 ":test_hello", 25 ":test_proc_macro", 26 ] 27 } else { 28 deps = [ ":hello_pw_log" ] 29 } 30} 31 32pw_rust_executable("hello") { 33 sources = [ 34 "main.rs", 35 "other.rs", 36 ] 37 deps = [ 38 ":a", 39 ":c", 40 ":proc_macro", 41 ] 42} 43 44# `hello_pw_log` is a re-implementation of `hello` with no_std support. 45# It uses `pw_log()` instead of `println!()`. 46pw_rust_executable("hello_pw_log") { 47 sources = [ 48 "bin/hello_pw_log/main.rs", 49 "other.rs", 50 ] 51 deps = [ 52 ":a", 53 ":c", 54 ":proc_macro", 55 ] 56 if (pw_rust_USE_STD) { 57 features = [ "std" ] 58 } 59} 60 61pw_rust_test("test_hello") { 62 sources = [ 63 "main.rs", 64 "other.rs", 65 ] 66 deps = [ 67 ":a", 68 ":c", 69 ":proc_macro", 70 ] 71} 72 73# The dep chain hello->a->b will exercise the functionality of both direct and 74# transitive deps for A 75pw_rust_library("a") { 76 crate_root = "a/lib.rs" 77 sources = [ "a/lib.rs" ] 78 deps = [ ":b" ] 79 if (pw_rust_USE_STD) { 80 features = [ "std" ] 81 } 82} 83 84pw_rust_library("b") { 85 crate_root = "b/lib.rs" 86 sources = [ "b/lib.rs" ] 87 deps = [ ":c" ] 88 if (pw_rust_USE_STD) { 89 features = [ "std" ] 90 } 91} 92 93pw_rust_library("c") { 94 crate_root = "c/lib.rs" 95 sources = [ "c/lib.rs" ] 96 if (pw_rust_USE_STD) { 97 features = [ "std" ] 98 } 99} 100 101pw_rust_proc_macro("proc_macro") { 102 crate_root = "proc_macro/lib.rs" 103 sources = [ "proc_macro/lib.rs" ] 104} 105 106pw_rust_test("test_proc_macro") { 107 sources = [ "proc_macro/test.rs" ] 108 deps = [ ":proc_macro" ] 109} 110