I wanted to use gn public/sources to separate between the public interface for a "feature", and the private interface (only used by tests). However, public/sources does not distinguish between test targets and production targets. Thus I end up with the following situation:
// This does not work because the unit test for foo_impl.h cannot depend on foo_impl.h
target (foo) {
public = [ foo.h ]
sources = [foo.cc, foo_impl.h, foo_impl.cc]
}
// This works, but the public/sources distinction is not useful since it's just .h vs .cc files, and including .cc files is already disallowed by style.
target (foo_public) {
public = [foo.h]
sources = [foo.cc]
deps = [:foo_impl]
}
target (foo_impl) {
public = [foo_impl.h]
sources = [foo_impl.cc]
}