Skip to content

Add .gni containing lists of files needed by GN #32

@AaronWebster

Description

@AaronWebster

This issue was copied from the upstream repository google/emboss.

Original issue: google#152
Original state: closed, created at: 2024-07-03T20:01:52Z, updated at: 2025-10-02T21:51:09Z, by @BenjaminLawson


Original description

Currently we have to maintain lists of Emboss files for use in GN build targets in Pigweed, including the compiler python files and the cpp_utils headers. It would be much more maintainable if there was a .gni file in upstream Emboss containing these file lists.


Discussion (copied comments)

Comment by @EricRahm on 2024-07-16T22:51:04Z:

I totally get why you want this, I'm just not sure how the emboss project will keep it up to date. We're currently only setup for bazel builds. Maybe adding a tool that can generate these files as part of the bazel build is what we want?


Comment by @EricRahm on 2024-07-17T01:00:34Z:

For concrete examples we have:

  1. Pigweed's build_defs.gni
  2. Fuchsia's build_defs.gni
  3. An unlanded but being prototyped version for Android:
python_library_host {
    name: "emboss_compiler",
    srcs: [
        "compiler/back_end/cpp/*.py",
        "compiler/back_end/util/*.py",
        "compiler/front_end/*.py",
        "compiler/util/*.py",
    ],
    data: [
        "compiler/back_end/cpp/generated_code_templates",
        "compiler/front_end/error_examples",
        "compiler/front_end/prelude.emb",
        "compiler/front_end/reserved_words",
    ],
}

Additionally each of those has some sort of target for the C++ header library as well, something along the lines of:

# GN
pw_source_set("cpp_utils") {
  # emboss depends on a separate checkout not included in pigweed, so
  # ignore gn check for this module.
  check_includes = false
  public = [
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_arithmetic.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_arithmetic_all_known_generated.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_arithmetic_maximum_operation_generated.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_array_view.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_bit_util.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_constant_view.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_cpp_types.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_cpp_util.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_defines.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_enum_view.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_maybe.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_memory_util.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_prelude.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_text_util.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_view_parameters.h",
  ]
  public_configs = [ ":disable_warnings" ]
  public_deps = [ pw_third_party_emboss_CONFIG ]
  visibility = [ "*" ]
}

# Cmake
pw_add_library(pw_third_party.emboss.cpp_utils INTERFACE
  HEADERS
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_arithmetic.h
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_arithmetic_all_known_generated.h
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_arithmetic_maximum_operation_generated.h
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_array_view.h
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_bit_util.h
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_constant_view.h
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_cpp_types.h
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_cpp_util.h
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_defines.h
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_enum_view.h
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_maybe.h
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_memory_util.h
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_prelude.h
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_text_util.h
    ${dir_pw_third_party_emboss}/runtime/cpp/emboss_view_parameters.h
  PUBLIC_INCLUDES
    ${dir_pw_third_party_emboss}
  PUBLIC_DEPS
    pw_third_party.emboss.config_assert
    pw_third_party.emboss._disable_warnings
)

So it'd be nice to cover that case too.


Comment by @studgeek on 2024-08-09T21:34:56Z:

358665524 is an example of the kinds of bugs we run into. This is because Fuchsia builds require all inputs to listed - https://fuchsia.dev/fuchsia-src/development/build/hermetic_actions.


Comment by @studgeek on 2024-08-13T02:57:55Z:

I created Pigweed issue Update emboss build rules to pull their file list from emboss repo [359386289] - Pigweed for the work that will need to happen in Pigweed alongside changes here in Emboss.


Comment by @studgeek on 2024-08-13T21:24:49Z:

google#171 provides a json file that handles this feature request.

I also filed google#172 as a follow-up issue to keep bazel and the new build_info.json in sync.


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions