Remove legacy OutputType setter from Target. It can no longer be mutated after construction, thus simplifying the code. Change-Id: If17b230d57d83d9daa140f6a9ecf80a96a6a6964 Reviewed-on: https://gn-review.googlesource.com/c/gn/+/29623 Commit-Queue: Matt Stark <msta@google.com> Reviewed-by: Takuto Ikuta <tikuta@google.com>
diff --git a/src/gn/starlark/crates/types/src/output_type.rs b/src/gn/starlark/crates/types/src/output_type.rs index abb5f20..94df689 100644 --- a/src/gn/starlark/crates/types/src/output_type.rs +++ b/src/gn/starlark/crates/types/src/output_type.rs
@@ -10,7 +10,6 @@ #[strum(serialize_all = "snake_case")] /// Copied from target.h's OutputType enum. pub enum OutputType { - // Unknown = 0 Group = 1, Executable, SharedLibrary,
diff --git a/src/gn/target.cc b/src/gn/target.cc index 8ef6476..0576773 100644 --- a/src/gn/target.cc +++ b/src/gn/target.cc
@@ -538,8 +538,6 @@ // static const char* Target::GetStringForOutputType(OutputType type) { switch (type) { - case UNKNOWN: - return "unknown"; case GROUP: return functions::kGroup; case EXECUTABLE: @@ -586,7 +584,6 @@ } bool Target::OnResolvedWithoutChecks(Err* err) { - DCHECK(output_type_ != UNKNOWN); DCHECK(toolchain_) << "Toolchain should have been set before resolving."; ScopedTrace trace(TraceItem::TRACE_ON_RESOLVED, label()); @@ -724,7 +721,6 @@ bool Target::SetToolchain(const Toolchain* toolchain, Err* err) { DCHECK(!toolchain_); - DCHECK_NE(UNKNOWN, output_type_); toolchain_ = toolchain; const Tool* tool = toolchain->GetToolForTargetFinalOutput(this); @@ -1081,7 +1077,6 @@ } break; } - case UNKNOWN: default: NOTREACHED(); }
diff --git a/src/gn/target.h b/src/gn/target.h index fd72994..d0e6b9d 100644 --- a/src/gn/target.h +++ b/src/gn/target.h
@@ -45,8 +45,7 @@ class Target : public Item { public: enum OutputType { - UNKNOWN, - GROUP, + GROUP = 1, EXECUTABLE, SHARED_LIBRARY, LOADABLE_MODULE, @@ -83,7 +82,7 @@ // to Scope for how this is determined. Target(const Settings* settings, const Label& label, - OutputType output_type = UNKNOWN, + OutputType output_type, const SourceFileSet& build_dependency_files = {}); ~Target() override; @@ -111,7 +110,6 @@ bool RunChecksAfterResolution(Err* err); OutputType output_type() const { return output_type_; } - void set_output_type(OutputType t) { output_type_ = t; } // True for targets that compile source code (all types of libraries and // executables). @@ -567,7 +565,7 @@ void CheckSourcesGenerated() const; bool CheckSourceSetLanguages(Err* err) const; - OutputType output_type_ = UNKNOWN; + const OutputType output_type_; std::string output_name_; bool output_prefix_override_ = false; SourceDir output_dir_;