yaml: Adding interface files

Adding 3 interfaces:
- Checkpoint
- Duration
- Statistic

Those yaml files will be used for generating dbus interface source code
files by the script under `gen/`.
It's unneeded for yocto build. However, presubmit build needs these
files to be existed since those interfaces are not merged to OpenBMC
yet.

Tested: Buildable
Google-Bug-Id: 296530445
Change-Id: Ida49772ff542456e1324e45583ab56c89ff3b11c
Signed-off-by: Michael Shen <gpgpgp@google.com>
diff --git a/.clang-format-ignore b/.clang-format-ignore
new file mode 100644
index 0000000..cc4412f
--- /dev/null
+++ b/.clang-format-ignore
@@ -0,0 +1,3 @@
+./build*/
+./subprojects/*/
+./gen/
diff --git a/gen/README b/gen/README
new file mode 100644
index 0000000..71182b5
--- /dev/null
+++ b/gen/README
@@ -0,0 +1,2 @@
+This directory contains generated meson.build files from sdbus++-gen-meson.
+Do not edit them by hand.
diff --git a/gen/meson.build b/gen/meson.build
new file mode 100644
index 0000000..b550c79
--- /dev/null
+++ b/gen/meson.build
@@ -0,0 +1,15 @@
+# Generated file; do not modify.
+sdbuspp_gen_meson_ver = run_command(
+    sdbuspp_gen_meson_prog,
+    '--version',
+    check: true,
+).stdout().strip().split('\n')[0]
+
+if sdbuspp_gen_meson_ver != 'sdbus++-gen-meson version 7'
+    warning('Generated meson files from wrong version of sdbus++-gen-meson.')
+    warning(
+        'Expected "sdbus++-gen-meson version 7", got:',
+        sdbuspp_gen_meson_ver
+    )
+endif
+
diff --git a/gen/regenerate-meson b/gen/regenerate-meson
new file mode 100755
index 0000000..a39ad64
--- /dev/null
+++ b/gen/regenerate-meson
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+REPO_ROOT=$(git rev-parse --show-toplevel)
+
+# Find sdbus++-gen-meson
+#   1. Check $SDBUSPP_GEN_MESON
+#   2. Check in $PATH
+#   3. Check in subprojects/sdbusplus
+if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
+    SDBUSPP_GEN_MESON="$(which sdbus++-gen-meson 2> /dev/null)"
+fi
+if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
+    SDBUSPP_GEN_MESON="$REPO_ROOT/subprojects/sdbusplus/tools/sdbus++-gen-meson"
+fi
+if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
+    echo "Cannot find sdbus++-gen-meson ($SDBUSPP_GEN_MESON)."
+    exit 1
+fi
+
+$SDBUSPP_GEN_MESON \
+    --command meson \
+    --directory "$REPO_ROOT/yaml" \
+    --output "$REPO_ROOT/gen"
diff --git a/gen/run-ci b/gen/run-ci
new file mode 100755
index 0000000..dba8109
--- /dev/null
+++ b/gen/run-ci
@@ -0,0 +1,16 @@
+#!/bin/bash
+cd "$(dirname "$0")" || exit
+find . -mindepth 1 -maxdepth 1 -type d -exec rm -r {} \;
+./regenerate-meson || exit
+rc=0
+git --no-pager diff --exit-code -- . || rc=$?
+untracked="$(git ls-files --others --exclude-standard -- .)" || rc=$?
+if [ -n "$untracked" ]; then
+    echo "Untracked files:" >&2
+    echo "$untracked" >&2
+    rc=1
+fi
+if ((rc != 0)); then
+    echo "Generated meson files differ from expected values" >&2
+    exit 1
+fi
diff --git a/gen/xyz/meson.build b/gen/xyz/meson.build
new file mode 100644
index 0000000..e4991ad
--- /dev/null
+++ b/gen/xyz/meson.build
@@ -0,0 +1,2 @@
+# Generated file; do not modify.
+subdir('openbmc_project')
diff --git a/gen/xyz/openbmc_project/Time/Boot/Checkpoint/meson.build b/gen/xyz/openbmc_project/Time/Boot/Checkpoint/meson.build
new file mode 100644
index 0000000..20a380c
--- /dev/null
+++ b/gen/xyz/openbmc_project/Time/Boot/Checkpoint/meson.build
@@ -0,0 +1,15 @@
+# Generated file; do not modify.
+generated_sources += custom_target(
+    'xyz/openbmc_project/Time/Boot/Checkpoint__cpp'.underscorify(),
+    input: [ '../../../../../../yaml/xyz/openbmc_project/Time/Boot/Checkpoint.interface.yaml',  ],
+    output: [ 'common.hpp', 'server.cpp', 'server.hpp', 'aserver.hpp', 'client.hpp',  ],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog, '--command', 'cpp',
+        '--output', meson.current_build_dir(),
+        '--tool', sdbusplusplus_prog,
+        '--directory', meson.current_source_dir() / '../../../../../../yaml',
+        'xyz/openbmc_project/Time/Boot/Checkpoint',
+    ],
+)
+
diff --git a/gen/xyz/openbmc_project/Time/Boot/Duration/meson.build b/gen/xyz/openbmc_project/Time/Boot/Duration/meson.build
new file mode 100644
index 0000000..a8809c4
--- /dev/null
+++ b/gen/xyz/openbmc_project/Time/Boot/Duration/meson.build
@@ -0,0 +1,15 @@
+# Generated file; do not modify.
+generated_sources += custom_target(
+    'xyz/openbmc_project/Time/Boot/Duration__cpp'.underscorify(),
+    input: [ '../../../../../../yaml/xyz/openbmc_project/Time/Boot/Duration.interface.yaml',  ],
+    output: [ 'common.hpp', 'server.cpp', 'server.hpp', 'aserver.hpp', 'client.hpp',  ],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog, '--command', 'cpp',
+        '--output', meson.current_build_dir(),
+        '--tool', sdbusplusplus_prog,
+        '--directory', meson.current_source_dir() / '../../../../../../yaml',
+        'xyz/openbmc_project/Time/Boot/Duration',
+    ],
+)
+
diff --git a/gen/xyz/openbmc_project/Time/Boot/Statistic/meson.build b/gen/xyz/openbmc_project/Time/Boot/Statistic/meson.build
new file mode 100644
index 0000000..db7d927
--- /dev/null
+++ b/gen/xyz/openbmc_project/Time/Boot/Statistic/meson.build
@@ -0,0 +1,15 @@
+# Generated file; do not modify.
+generated_sources += custom_target(
+    'xyz/openbmc_project/Time/Boot/Statistic__cpp'.underscorify(),
+    input: [ '../../../../../../yaml/xyz/openbmc_project/Time/Boot/Statistic.interface.yaml',  ],
+    output: [ 'common.hpp', 'server.cpp', 'server.hpp', 'aserver.hpp', 'client.hpp',  ],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog, '--command', 'cpp',
+        '--output', meson.current_build_dir(),
+        '--tool', sdbusplusplus_prog,
+        '--directory', meson.current_source_dir() / '../../../../../../yaml',
+        'xyz/openbmc_project/Time/Boot/Statistic',
+    ],
+)
+
diff --git a/gen/xyz/openbmc_project/Time/Boot/meson.build b/gen/xyz/openbmc_project/Time/Boot/meson.build
new file mode 100644
index 0000000..be9c07f
--- /dev/null
+++ b/gen/xyz/openbmc_project/Time/Boot/meson.build
@@ -0,0 +1,46 @@
+# Generated file; do not modify.
+subdir('Checkpoint')
+generated_others += custom_target(
+    'xyz/openbmc_project/Time/Boot/Checkpoint__markdown'.underscorify(),
+    input: [ '../../../../../yaml/xyz/openbmc_project/Time/Boot/Checkpoint.interface.yaml',  ],
+    output: [ 'Checkpoint.md' ],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog, '--command', 'markdown',
+        '--output', meson.current_build_dir(),
+        '--tool', sdbusplusplus_prog,
+        '--directory', meson.current_source_dir() / '../../../../../yaml',
+        'xyz/openbmc_project/Time/Boot/Checkpoint',
+    ],
+)
+
+subdir('Duration')
+generated_others += custom_target(
+    'xyz/openbmc_project/Time/Boot/Duration__markdown'.underscorify(),
+    input: [ '../../../../../yaml/xyz/openbmc_project/Time/Boot/Duration.interface.yaml',  ],
+    output: [ 'Duration.md' ],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog, '--command', 'markdown',
+        '--output', meson.current_build_dir(),
+        '--tool', sdbusplusplus_prog,
+        '--directory', meson.current_source_dir() / '../../../../../yaml',
+        'xyz/openbmc_project/Time/Boot/Duration',
+    ],
+)
+
+subdir('Statistic')
+generated_others += custom_target(
+    'xyz/openbmc_project/Time/Boot/Statistic__markdown'.underscorify(),
+    input: [ '../../../../../yaml/xyz/openbmc_project/Time/Boot/Statistic.interface.yaml',  ],
+    output: [ 'Statistic.md' ],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog, '--command', 'markdown',
+        '--output', meson.current_build_dir(),
+        '--tool', sdbusplusplus_prog,
+        '--directory', meson.current_source_dir() / '../../../../../yaml',
+        'xyz/openbmc_project/Time/Boot/Statistic',
+    ],
+)
+
diff --git a/gen/xyz/openbmc_project/Time/meson.build b/gen/xyz/openbmc_project/Time/meson.build
new file mode 100644
index 0000000..915b4bc
--- /dev/null
+++ b/gen/xyz/openbmc_project/Time/meson.build
@@ -0,0 +1,2 @@
+# Generated file; do not modify.
+subdir('Boot')
diff --git a/gen/xyz/openbmc_project/meson.build b/gen/xyz/openbmc_project/meson.build
new file mode 100644
index 0000000..fe5aff0
--- /dev/null
+++ b/gen/xyz/openbmc_project/meson.build
@@ -0,0 +1,2 @@
+# Generated file; do not modify.
+subdir('Time')
diff --git a/meson.build b/meson.build
index 2672e3c..cd5e04f 100644
--- a/meson.build
+++ b/meson.build
@@ -15,6 +15,23 @@
   include_directories('include'),
 ]
 
+sdbusplus_dep = dependency('sdbusplus', required : false)
+
+generated_sources = []
+generated_others = []
+if get_option('yocto').disabled()
+  ### For local phosphor-dbus-interfaces only
+  sdbusplusplus_prog = find_program('sdbus++', native: true)
+  sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true)
+  sdbusplusplus_depfiles = files()
+  if sdbusplus_dep.type_name() == 'internal'
+      sdbusplusplus_depfiles = subproject('sdbusplus').get_variable('sdbusplusplus_depfiles')
+  endif
+  subdir('gen')
+  subdir('gen/xyz')
+  boot_time_monitor_incs += include_directories('gen')
+endif
+
 subdir('src')
 subdir('service_files')
 
diff --git a/meson_options.txt b/meson_options.txt
index 0fc2767..ad4edc1 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1 +1,2 @@
 option('tests', type: 'feature', description: 'Build tests')
+option('yocto', type : 'feature', value : 'disabled')
diff --git a/src/meson.build b/src/meson.build
index 3cd01e4..9ee614d 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,5 +1,5 @@
 boost_dep = dependency('boost', required : false)
-sdbusplus_dep = dependency('sdbusplus', required : false)
+phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
 
 fmt_dep = dependency('fmt', required: false)
 if not fmt_dep.found()
@@ -18,6 +18,7 @@
   boost_dep,
   sdbusplus_dep,
   fmt_dep,
+  phosphor_dbus_interfaces_dep,
 ]
 
 boot_time_monitor_lib = static_library(
@@ -25,6 +26,7 @@
   'host_monitor_app.cpp',
   'utils.cpp',
   'boot_manager.cpp',
+  generated_sources,
   include_directories: boot_time_monitor_incs,
   implicit_include_directories: false,
   dependencies: boot_time_monitor_pre,
diff --git a/yaml/xyz/openbmc_project/Time/Boot/Checkpoint.interface.yaml b/yaml/xyz/openbmc_project/Time/Boot/Checkpoint.interface.yaml
new file mode 100644
index 0000000..a84bfe0
--- /dev/null
+++ b/yaml/xyz/openbmc_project/Time/Boot/Checkpoint.interface.yaml
@@ -0,0 +1,40 @@
+description: >
+    This interface helps users to record the end time of each stage (we called
+    checkpoint in this interface).
+methods:
+    - name: SetCheckpoint
+      description: >
+        Labeling this moment as a checkpoint for a specific stage.
+      parameters:
+        - name: CheckpointName
+          type: string
+          default: ""
+          description: >
+            Checkpoint name for this moment.
+        - name: WallTime
+          type: int64
+          default: 0
+          description: >
+            Seconds that has elapsed since Jan 1st 1970 00:00:00 (Epoch).
+            If this value is 0, then BMC will fetch wall time internally
+            instead.
+        - name: SelfMeasuredDuration
+          type: int64
+          default: 0
+          description: >
+            Duration in second that is measured by the sender itself.
+            If this parameter is set (non zero), then BMC will help to calculate
+            the transition time from last checkpoint to current stage.
+      errors:
+        - xyz.openbmc_project.Common.Error.InvalidArgument
+    - name: GetCheckpointList
+      description: >
+        Get the list of checkpoints.
+      returns:
+          - name: CheckpointList
+            type: array[struct[string, int64, int64]]
+            description: >
+                A list of checkpoints.
+    - name: RebootComplete
+      description: >
+        Mark current reboot process as completed.
diff --git a/yaml/xyz/openbmc_project/Time/Boot/Duration.interface.yaml b/yaml/xyz/openbmc_project/Time/Boot/Duration.interface.yaml
new file mode 100644
index 0000000..5d34d4f
--- /dev/null
+++ b/yaml/xyz/openbmc_project/Time/Boot/Duration.interface.yaml
@@ -0,0 +1,27 @@
+description: >
+    This interface helps users to record the self measured duration.
+methods:
+    - name: SetDuration
+      description: >
+        Store any durations that is related to this reboot.
+      parameters:
+        - name: DurationName
+          type: string
+          default: ""
+          description: >
+            Duration name for this moment.
+        - name: Duration
+          type: int64
+          default: 0
+          description: >
+            Duration in second.
+      errors:
+        - xyz.openbmc_project.Common.Error.InvalidArgument
+    - name: GetAdditionalDurations
+      description: >
+        Get all the additional durations.
+      returns:
+          - name: durationsList
+            type: array[struct[string, int64]]
+            description: >
+                A list of additional durations.
diff --git a/yaml/xyz/openbmc_project/Time/Boot/Statistic.interface.yaml b/yaml/xyz/openbmc_project/Time/Boot/Statistic.interface.yaml
new file mode 100644
index 0000000..cb740ea
--- /dev/null
+++ b/yaml/xyz/openbmc_project/Time/Boot/Statistic.interface.yaml
@@ -0,0 +1,10 @@
+description: >
+    Statistics information for a reboot.
+properties:
+    - name: IsRebooting
+      type: boolean
+      default: false
+      description: >
+        Returns whether this machine is rebooting.
+      flags:
+        - readonly