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 #include "gn/rust_substitution_type.h"
6
7 #include <stddef.h>
8 #include <stdlib.h>
9
10 #include "gn/err.h"
11 #include "gn/substitution_type.h"
12
13 const SubstitutionTypes RustSubstitutions = {
14 &kRustSubstitutionCrateName, &kRustSubstitutionCrateType,
15 &kRustSubstitutionRustDeps, &kRustSubstitutionRustFlags,
16 &kRustSubstitutionRustEnv, &kRustSubstitutionExterns,
17 };
18
19 // Valid for Rust tools.
20 const Substitution kRustSubstitutionCrateName = {"{{crate_name}}",
21 "crate_name"};
22 const Substitution kRustSubstitutionCrateType = {"{{crate_type}}",
23 "crate_type"};
24 const Substitution kRustSubstitutionExterns = {"{{externs}}", "externs"};
25 const Substitution kRustSubstitutionRustDeps = {"{{rustdeps}}", "rustdeps"};
26 const Substitution kRustSubstitutionRustEnv = {"{{rustenv}}", "rustenv"};
27 const Substitution kRustSubstitutionRustFlags = {"{{rustflags}}", "rustflags"};
28
IsValidRustSubstitution(const Substitution * type)29 bool IsValidRustSubstitution(const Substitution* type) {
30 return IsValidToolSubstitution(type) || IsValidSourceSubstitution(type) ||
31 type == &SubstitutionOutputDir ||
32 type == &SubstitutionOutputExtension ||
33 type == &kRustSubstitutionCrateName ||
34 type == &kRustSubstitutionCrateType ||
35 type == &kRustSubstitutionExterns ||
36 type == &kRustSubstitutionRustDeps ||
37 type == &kRustSubstitutionRustEnv ||
38 type == &kRustSubstitutionRustFlags;
39 }
40