google / emboss

Emboss is a tool for generating code that reads and writes binary data structures.
Apache License 2.0
71 stars 21 forks source link

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

Open BenjaminLawson opened 3 months ago

BenjaminLawson commented 3 months ago

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.

EricRahm commented 2 months ago

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?

EricRahm commented 2 months ago

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.

studgeek commented 1 month ago

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.

studgeek commented 1 month ago

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.

studgeek commented 1 month ago

https://github.com/google/emboss/pull/171 provides a json file that handles this feature request.

I also filed https://github.com/google/emboss/issues/172 as a follow-up issue to keep bazel and the new build_info.json in sync.