Skip to content

Commit

Permalink
Enforce that outputs in the codegen are known rather than dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Oct 12, 2022
1 parent 8d2e9e5 commit c758819
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 4 deletions.
23 changes: 19 additions & 4 deletions build/chip/chip_codegen.gni
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,25 @@ import("$dir_pw_build/python.gni")
# generator
# Name of the generator to use (e.g. java, cpp-app)
#
# outputs
# Explicit names of the expected outputs. Enforced to validate that
# expected data from input idl files
#
# NOTE: content of "outputs" is currently verified
# but it is still forced to be included in the codegen command to
# have build rules explicit.
#
# Example usage:
#
# chip_codegen("java-jni-generate") {
# idl = "controler-clusters.matter"
# idl = "controller-clusters.matter"
# generator = "java"
#
# outputs = [
# "jni/IdentifyClient-ReadImpl.cpp",
# "jni/IdentifyClient-InvokeSubscribeImpl.cpp",
# # ... more to follow
# ]
# }
#
template("chip_codegen") {
Expand All @@ -60,6 +73,8 @@ template("chip_codegen") {
"list lines",
[ _idl_file ])

assert(_output_files == invoker.outputs, "Expected outputs must match.")

args = [
"--generator",
_generator,
Expand All @@ -73,10 +88,10 @@ template("chip_codegen") {

inputs = [ _idl_file ]
sources = [ _idl_file ]
outputs = []

foreach(name, _output_files) {
outputs += [ "$target_gen_dir/${name}" ]
outputs = []
foreach (name, invoker.outputs) {
outputs += ["${target_gen_dir}/${name}"]
}
}
}
10 changes: 10 additions & 0 deletions examples/dynamic-bridge-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ assert(chip_build_tools)
chip_codegen("chip-bridge-codegen") {
idl = "${chip_root}/examples/bridge-app/bridge-common/bridge-app.matter"
generator = "bridge"

outputs = [
"bridge/OnOff.h",
"bridge/LevelControl.h",
"bridge/Descriptor.h",
"bridge/Switch.h",
"bridge/TemperatureMeasurement.h",
"bridge/BridgeClustersImpl.h",
"bridge/BridgeGlobalStructs.h",
]
}

executable("dynamic-chip-bridge-app") {
Expand Down
133 changes: 133 additions & 0 deletions src/controller/data_model/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,139 @@ if (current_os == "android") {
chip_codegen("java-jni-generate") {
idl = "controller-clusters.matter"
generator = "java"

outputs = [
"jni/IdentifyClient-ReadImpl.cpp",
"jni/IdentifyClient-InvokeSubscribeImpl.cpp",
"jni/GroupsClient-ReadImpl.cpp",
"jni/GroupsClient-InvokeSubscribeImpl.cpp",
"jni/ScenesClient-ReadImpl.cpp",
"jni/ScenesClient-InvokeSubscribeImpl.cpp",
"jni/OnOffClient-ReadImpl.cpp",
"jni/OnOffClient-InvokeSubscribeImpl.cpp",
"jni/OnOffSwitchConfigurationClient-ReadImpl.cpp",
"jni/OnOffSwitchConfigurationClient-InvokeSubscribeImpl.cpp",
"jni/LevelControlClient-ReadImpl.cpp",
"jni/LevelControlClient-InvokeSubscribeImpl.cpp",
"jni/BinaryInputBasicClient-ReadImpl.cpp",
"jni/BinaryInputBasicClient-InvokeSubscribeImpl.cpp",
"jni/DescriptorClient-ReadImpl.cpp",
"jni/DescriptorClient-InvokeSubscribeImpl.cpp",
"jni/BindingClient-ReadImpl.cpp",
"jni/BindingClient-InvokeSubscribeImpl.cpp",
"jni/AccessControlClient-ReadImpl.cpp",
"jni/AccessControlClient-InvokeSubscribeImpl.cpp",
"jni/ActionsClient-ReadImpl.cpp",
"jni/ActionsClient-InvokeSubscribeImpl.cpp",
"jni/BasicClient-ReadImpl.cpp",
"jni/BasicClient-InvokeSubscribeImpl.cpp",
"jni/OtaSoftwareUpdateProviderClient-ReadImpl.cpp",
"jni/OtaSoftwareUpdateProviderClient-InvokeSubscribeImpl.cpp",
"jni/OtaSoftwareUpdateRequestorClient-ReadImpl.cpp",
"jni/OtaSoftwareUpdateRequestorClient-InvokeSubscribeImpl.cpp",
"jni/LocalizationConfigurationClient-ReadImpl.cpp",
"jni/LocalizationConfigurationClient-InvokeSubscribeImpl.cpp",
"jni/TimeFormatLocalizationClient-ReadImpl.cpp",
"jni/TimeFormatLocalizationClient-InvokeSubscribeImpl.cpp",
"jni/UnitLocalizationClient-ReadImpl.cpp",
"jni/UnitLocalizationClient-InvokeSubscribeImpl.cpp",
"jni/PowerSourceConfigurationClient-ReadImpl.cpp",
"jni/PowerSourceConfigurationClient-InvokeSubscribeImpl.cpp",
"jni/PowerSourceClient-ReadImpl.cpp",
"jni/PowerSourceClient-InvokeSubscribeImpl.cpp",
"jni/GeneralCommissioningClient-ReadImpl.cpp",
"jni/GeneralCommissioningClient-InvokeSubscribeImpl.cpp",
"jni/NetworkCommissioningClient-ReadImpl.cpp",
"jni/NetworkCommissioningClient-InvokeSubscribeImpl.cpp",
"jni/DiagnosticLogsClient-ReadImpl.cpp",
"jni/DiagnosticLogsClient-InvokeSubscribeImpl.cpp",
"jni/GeneralDiagnosticsClient-ReadImpl.cpp",
"jni/GeneralDiagnosticsClient-InvokeSubscribeImpl.cpp",
"jni/SoftwareDiagnosticsClient-ReadImpl.cpp",
"jni/SoftwareDiagnosticsClient-InvokeSubscribeImpl.cpp",
"jni/ThreadNetworkDiagnosticsClient-ReadImpl.cpp",
"jni/ThreadNetworkDiagnosticsClient-InvokeSubscribeImpl.cpp",
"jni/WiFiNetworkDiagnosticsClient-ReadImpl.cpp",
"jni/WiFiNetworkDiagnosticsClient-InvokeSubscribeImpl.cpp",
"jni/EthernetNetworkDiagnosticsClient-ReadImpl.cpp",
"jni/EthernetNetworkDiagnosticsClient-InvokeSubscribeImpl.cpp",
"jni/BridgedDeviceBasicClient-ReadImpl.cpp",
"jni/BridgedDeviceBasicClient-InvokeSubscribeImpl.cpp",
"jni/SwitchClient-ReadImpl.cpp",
"jni/SwitchClient-InvokeSubscribeImpl.cpp",
"jni/AdministratorCommissioningClient-ReadImpl.cpp",
"jni/AdministratorCommissioningClient-InvokeSubscribeImpl.cpp",
"jni/OperationalCredentialsClient-ReadImpl.cpp",
"jni/OperationalCredentialsClient-InvokeSubscribeImpl.cpp",
"jni/GroupKeyManagementClient-ReadImpl.cpp",
"jni/GroupKeyManagementClient-InvokeSubscribeImpl.cpp",
"jni/FixedLabelClient-ReadImpl.cpp",
"jni/FixedLabelClient-InvokeSubscribeImpl.cpp",
"jni/UserLabelClient-ReadImpl.cpp",
"jni/UserLabelClient-InvokeSubscribeImpl.cpp",
"jni/BooleanStateClient-ReadImpl.cpp",
"jni/BooleanStateClient-InvokeSubscribeImpl.cpp",
"jni/ModeSelectClient-ReadImpl.cpp",
"jni/ModeSelectClient-InvokeSubscribeImpl.cpp",
"jni/DoorLockClient-ReadImpl.cpp",
"jni/DoorLockClient-InvokeSubscribeImpl.cpp",
"jni/WindowCoveringClient-ReadImpl.cpp",
"jni/WindowCoveringClient-InvokeSubscribeImpl.cpp",
"jni/BarrierControlClient-ReadImpl.cpp",
"jni/BarrierControlClient-InvokeSubscribeImpl.cpp",
"jni/PumpConfigurationAndControlClient-ReadImpl.cpp",
"jni/PumpConfigurationAndControlClient-InvokeSubscribeImpl.cpp",
"jni/ThermostatClient-ReadImpl.cpp",
"jni/ThermostatClient-InvokeSubscribeImpl.cpp",
"jni/FanControlClient-ReadImpl.cpp",
"jni/FanControlClient-InvokeSubscribeImpl.cpp",
"jni/ThermostatUserInterfaceConfigurationClient-ReadImpl.cpp",
"jni/ThermostatUserInterfaceConfigurationClient-InvokeSubscribeImpl.cpp",
"jni/ColorControlClient-ReadImpl.cpp",
"jni/ColorControlClient-InvokeSubscribeImpl.cpp",
"jni/BallastConfigurationClient-ReadImpl.cpp",
"jni/BallastConfigurationClient-InvokeSubscribeImpl.cpp",
"jni/IlluminanceMeasurementClient-ReadImpl.cpp",
"jni/IlluminanceMeasurementClient-InvokeSubscribeImpl.cpp",
"jni/TemperatureMeasurementClient-ReadImpl.cpp",
"jni/TemperatureMeasurementClient-InvokeSubscribeImpl.cpp",
"jni/PressureMeasurementClient-ReadImpl.cpp",
"jni/PressureMeasurementClient-InvokeSubscribeImpl.cpp",
"jni/FlowMeasurementClient-ReadImpl.cpp",
"jni/FlowMeasurementClient-InvokeSubscribeImpl.cpp",
"jni/RelativeHumidityMeasurementClient-ReadImpl.cpp",
"jni/RelativeHumidityMeasurementClient-InvokeSubscribeImpl.cpp",
"jni/OccupancySensingClient-ReadImpl.cpp",
"jni/OccupancySensingClient-InvokeSubscribeImpl.cpp",
"jni/WakeOnLanClient-ReadImpl.cpp",
"jni/WakeOnLanClient-InvokeSubscribeImpl.cpp",
"jni/ChannelClient-ReadImpl.cpp",
"jni/ChannelClient-InvokeSubscribeImpl.cpp",
"jni/TargetNavigatorClient-ReadImpl.cpp",
"jni/TargetNavigatorClient-InvokeSubscribeImpl.cpp",
"jni/MediaPlaybackClient-ReadImpl.cpp",
"jni/MediaPlaybackClient-InvokeSubscribeImpl.cpp",
"jni/MediaInputClient-ReadImpl.cpp",
"jni/MediaInputClient-InvokeSubscribeImpl.cpp",
"jni/LowPowerClient-ReadImpl.cpp",
"jni/LowPowerClient-InvokeSubscribeImpl.cpp",
"jni/KeypadInputClient-ReadImpl.cpp",
"jni/KeypadInputClient-InvokeSubscribeImpl.cpp",
"jni/ContentLauncherClient-ReadImpl.cpp",
"jni/ContentLauncherClient-InvokeSubscribeImpl.cpp",
"jni/AudioOutputClient-ReadImpl.cpp",
"jni/AudioOutputClient-InvokeSubscribeImpl.cpp",
"jni/ApplicationLauncherClient-ReadImpl.cpp",
"jni/ApplicationLauncherClient-InvokeSubscribeImpl.cpp",
"jni/ApplicationBasicClient-ReadImpl.cpp",
"jni/ApplicationBasicClient-InvokeSubscribeImpl.cpp",
"jni/AccountLoginClient-ReadImpl.cpp",
"jni/AccountLoginClient-InvokeSubscribeImpl.cpp",
"jni/ElectricalMeasurementClient-ReadImpl.cpp",
"jni/ElectricalMeasurementClient-InvokeSubscribeImpl.cpp",
"jni/TestClusterClient-ReadImpl.cpp",
"jni/TestClusterClient-InvokeSubscribeImpl.cpp",
]
}

source_set("java-jni-sources") {
Expand Down

0 comments on commit c758819

Please sign in to comment.