gn public/sources does not have the intended effect?

Skip to first unread message

Erik Chen

May 31, 2024, 2:44:08 PMMay 31
to gn-dev
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_impl.h,]

// 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 = []
  deps = [:foo_impl]
target (foo_impl) {
  public = [foo_impl.h]
  sources = []

Brett Wilson

May 31, 2024, 3:13:46 PMMay 31
to Erik Chen, gn-dev
Did you see the "friend" tag? You can list other targets that can use your private files which might help with your test.


Erik Chen

May 31, 2024, 6:07:07 PMMay 31
to Brett Wilson, gn-dev
Perfect! This is exactly what I was looking for. Thanks :)
Reply all
Reply to author
0 new messages