Use variables for MRW XML filename and path

Create an mrw-xml bbclass that has variables for the
MRW XML filename and path to it.  Then, changes all users
of the MRW XML to inherit that class and use those variables.

The filename will default to ${MACHINE}.xml if it hasn't already
been set to something else, such as in a .conf file.

This is done so that the file can be something other than
${MACHINE}.xml.

Change-Id: Ia7021e5a5d5e7946829e58688250aa64250cb00e
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/occ/openpower-occ-control-config-mrw-native.bb b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/occ/openpower-occ-control-config-mrw-native.bb
index aa831a5..887b741 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/occ/openpower-occ-control-config-mrw-native.bb
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/occ/openpower-occ-control-config-mrw-native.bb
@@ -5,6 +5,7 @@
 inherit obmc-phosphor-utils
 inherit obmc-phosphor-license
 inherit openpower-occ-control
+inherit mrw-xml
 
 PROVIDES += "virtual/openpower-occ-control-config-native"
 DEPENDS += "mrw-native mrw-perl-tools-native"
@@ -14,6 +15,6 @@
     install -d ${YAML_DEST}/
     ${STAGING_BINDIR_NATIVE}/perl-native/perl \
     ${STAGING_BINDIR_NATIVE}/gen_occ_map.pl \
-    -i ${STAGING_DATADIR_NATIVE}/obmc-mrw/${MACHINE}.xml \
+    -i ${mrw_datadir}/${MRW_XML} \
     -o ${YAML_DEST}/occ_sensor.yaml
 }
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/vpd/openpower-fru-inventory-mrw-native.bb b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/vpd/openpower-fru-inventory-mrw-native.bb
index 01ed362..6eb76ac 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/vpd/openpower-fru-inventory-mrw-native.bb
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/vpd/openpower-fru-inventory-mrw-native.bb
@@ -4,6 +4,7 @@
 inherit native
 inherit obmc-phosphor-license
 inherit openpower-fru-vpd
+inherit mrw-xml
 
 DEPENDS += " \
            mrw-native \
@@ -21,7 +22,7 @@
 
         ${bindir}/perl-native/perl \
             ${bindir}/gen_openpower_fru.pl \
-            -m ${datadir}/obmc-mrw/${MACHINE}.xml \
+            -m ${mrw_datadir}/${MRW_XML} \
             -c ${vpdlayout_datadir}/layout.yaml \
             -o ${DEST}/inventory
 }
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/vpd/openpower-fru-properties-mrw-native.bb b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/vpd/openpower-fru-properties-mrw-native.bb
index 7119484..2dc5820 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/vpd/openpower-fru-properties-mrw-native.bb
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/vpd/openpower-fru-properties-mrw-native.bb
@@ -4,6 +4,7 @@
 inherit native
 inherit obmc-phosphor-license
 inherit openpower-fru-vpd
+inherit mrw-xml
 
 SRC_URI += "file://config.yaml"
 
@@ -22,7 +23,7 @@
 
         ${bindir}/perl-native/perl \
             ${bindir}/gen_fru_properties.pl \
-            -m ${datadir}/obmc-mrw/${MACHINE}.xml \
+            -m ${mrw_datadir}/${MRW_XML} \
             -c config.yaml \
             -o ${DEST}/out.yaml
 }
diff --git a/meta-phosphor/classes/mrw-xml.bbclass b/meta-phosphor/classes/mrw-xml.bbclass
new file mode 100644
index 0000000..5a9c773
--- /dev/null
+++ b/meta-phosphor/classes/mrw-xml.bbclass
@@ -0,0 +1,2 @@
+MRW_XML ??= "${MACHINE}.xml"
+mrw_datadir = "${datadir}/obmc-mrw"
diff --git a/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan-control-fan-config-mrw-native.bb b/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan-control-fan-config-mrw-native.bb
index 1eadadf..7ae05ce 100644
--- a/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan-control-fan-config-mrw-native.bb
+++ b/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan-control-fan-config-mrw-native.bb
@@ -4,6 +4,7 @@
 inherit native
 inherit obmc-phosphor-license
 inherit phosphor-fan
+inherit mrw-xml
 
 DEPENDS += " \
            mrw-native \
@@ -17,7 +18,7 @@
 do_compile() {
     ${bindir}/perl-native/perl \
         ${bindir}/gen_fan_zone_yaml.pl \
-        -i ${datadir}/obmc-mrw/${MACHINE}.xml \
+        -i ${mrw_datadir}/${MRW_XML} \
         -o ${S}/fans.yaml
 }
 
diff --git a/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan-presence-mrw-native.bb b/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan-presence-mrw-native.bb
index 9d19847..47dc2a4 100644
--- a/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan-presence-mrw-native.bb
+++ b/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan-presence-mrw-native.bb
@@ -4,6 +4,7 @@
 inherit native
 inherit obmc-phosphor-license
 inherit phosphor-fan
+inherit mrw-xml
 
 DEPENDS += " \
            mrw-native \
@@ -20,6 +21,6 @@
 
         ${bindir}/perl-native/perl \
             ${bindir}/gen_presence_yaml.pl \
-            -i ${datadir}/obmc-mrw/${MACHINE}.xml \
+            -i ${mrw_datadir}/${MRW_XML} \
             -o ${DEST}/config.yaml
 }
diff --git a/meta-phosphor/common/recipes-phosphor/inventory/obmc-inventory.bb b/meta-phosphor/common/recipes-phosphor/inventory/obmc-inventory.bb
index baab633..db3a5b4 100644
--- a/meta-phosphor/common/recipes-phosphor/inventory/obmc-inventory.bb
+++ b/meta-phosphor/common/recipes-phosphor/inventory/obmc-inventory.bb
@@ -2,6 +2,8 @@
 DESCRIPTION = "Generates inventory data from the machine readable workbook"
 PR = "r1"
 
+inherit mrw-xml
+
 S = "${WORKDIR}/git"
 
 PROVIDES += "virtual/obmc-inventory-data"
@@ -20,7 +22,7 @@
 
 do_compile() {
     ${STAGING_BINDIR_NATIVE}/perl-native/perl ${S}/inventory.pl \
-        -x ${STAGING_DATADIR_NATIVE}/obmc-mrw/${MACHINE}.xml -o inventory.json
+        -x ${STAGING_DIR_NATIVE}${mrw_datadir}/${MRW_XML} -o inventory.json
 }
 
 do_install() {
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-inventory-mrw-native.bb b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-inventory-mrw-native.bb
index 0c512fc..795c9b9 100644
--- a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-inventory-mrw-native.bb
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-inventory-mrw-native.bb
@@ -3,6 +3,7 @@
 
 inherit native
 inherit phosphor-ipmi-fru
+inherit mrw-xml
 
 require phosphor-ipmi-fru.inc
 
@@ -22,7 +23,7 @@
 
     ${bindir}/perl-native/perl \
         ${bindir}/gen_ipmi_fru.pl \
-        -i ${datadir}/obmc-mrw/${MACHINE}.xml \
+        -i ${mrw_datadir}/${MRW_XML} \
         -m ${hostfw_datadir}/config.yaml \
         -o ${DEST}/config.yaml
 }
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-mrw-native.bb b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-mrw-native.bb
index 0d250e7..0a1c8bd 100644
--- a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-mrw-native.bb
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-properties-mrw-native.bb
@@ -4,6 +4,7 @@
 inherit native
 inherit obmc-phosphor-license
 inherit phosphor-ipmi-fru
+inherit mrw-xml
 
 SRC_URI += "file://config.yaml"
 
@@ -22,7 +23,7 @@
 
         ${bindir}/perl-native/perl \
             ${bindir}/gen_fru_properties.pl \
-            -m ${datadir}/obmc-mrw/${MACHINE}.xml \
+            -m ${mrw_datadir}/${MRW_XML} \
             -c config.yaml \
             -o ${DEST}/extra-properties.yaml
 }
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-read-inventory-mrw-native.bb b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-read-inventory-mrw-native.bb
index 5b0ca60..3c5e36f 100644
--- a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-read-inventory-mrw-native.bb
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-fru-read-inventory-mrw-native.bb
@@ -3,6 +3,7 @@
 
 inherit native
 inherit phosphor-ipmi-host
+inherit mrw-xml
 
 require phosphor-ipmi-host.inc
 
@@ -20,7 +21,7 @@
 
     ${bindir}/perl-native/perl \
         ${bindir}/gen_ipmi_fru.pl \
-        -i ${datadir}/obmc-mrw/${MACHINE}.xml \
+        -i ${mrw_datadir}/${MRW_XML} \
         -m ${hostfw_datadir}/config.yaml \
         -o ${DEST}/config.yaml
 }
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel-mrw-native.bb b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel-mrw-native.bb
index b852937..f04d89f 100644
--- a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel-mrw-native.bb
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel-mrw-native.bb
@@ -4,6 +4,7 @@
 inherit native
 inherit obmc-phosphor-license
 inherit phosphor-ipmi-host
+inherit mrw-xml
 
 SRC_URI += "file://config.yaml"
 
@@ -22,7 +23,7 @@
 
         ${bindir}/perl-native/perl \
             ${bindir}/gen_ipmi_sel.pl \
-            -i ${datadir}/obmc-mrw/${MACHINE}.xml \
+            -i ${mrw_datadir}/${MRW_XML} \
             -m config.yaml \
             -o ${DEST}/invsensor.yaml
 }
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-sensor-inventory-mrw-native.bb b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-sensor-inventory-mrw-native.bb
index a9955fe..67c6996 100644
--- a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-sensor-inventory-mrw-native.bb
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-sensor-inventory-mrw-native.bb
@@ -5,6 +5,7 @@
 inherit obmc-phosphor-license
 inherit phosphor-ipmi-host
 inherit pythonnative
+inherit mrw-xml
 
 DEPENDS += " \
            mrw-native \
@@ -24,7 +25,7 @@
 
         ${bindir}/perl-native/perl \
             ${bindir}/gen_ipmi_sensor.pl \
-            -i ${datadir}/obmc-mrw/${MACHINE}.xml \
+            -i ${mrw_datadir}/${MRW_XML} \
             -m ${sensor_yamldir}/config.yaml \
             -o ${DEST}/sensor.yaml
 }
diff --git a/meta-phosphor/common/recipes-phosphor/leds/phosphor-led-manager-config-mrw-native.bb b/meta-phosphor/common/recipes-phosphor/leds/phosphor-led-manager-config-mrw-native.bb
index fb3259b..ef14030 100644
--- a/meta-phosphor/common/recipes-phosphor/leds/phosphor-led-manager-config-mrw-native.bb
+++ b/meta-phosphor/common/recipes-phosphor/leds/phosphor-led-manager-config-mrw-native.bb
@@ -4,6 +4,7 @@
 inherit native
 inherit obmc-phosphor-utils
 inherit obmc-phosphor-license
+inherit mrw-xml
 
 PROVIDES += "virtual/phosphor-led-manager-config-native"
 DEPENDS += "mrw-native mrw-perl-tools-native"
@@ -17,7 +18,7 @@
         install -d ${DEST}/
         ${STAGING_BINDIR_NATIVE}/perl-native/perl \
         ${STAGING_BINDIR_NATIVE}/gen_led_groups.pl \
-        -i ${STAGING_DATADIR_NATIVE}/obmc-mrw/${MACHINE}.xml \
+        -i ${mrw_datadir}/${MRW_XML} \
         -o ${DEST}/led.yaml
     fi
 }
diff --git a/meta-phosphor/common/recipes-phosphor/logging/phosphor-logging-callouts-mrw-native.bb b/meta-phosphor/common/recipes-phosphor/logging/phosphor-logging-callouts-mrw-native.bb
index 4981626..96852d4 100644
--- a/meta-phosphor/common/recipes-phosphor/logging/phosphor-logging-callouts-mrw-native.bb
+++ b/meta-phosphor/common/recipes-phosphor/logging/phosphor-logging-callouts-mrw-native.bb
@@ -4,6 +4,7 @@
 inherit native
 inherit obmc-phosphor-license
 inherit phosphor-logging
+inherit mrw-xml
 
 DEPENDS += " \
            mrw-native \
@@ -20,6 +21,6 @@
 
         ${bindir}/perl-native/perl \
             ${bindir}/gen_callouts.pl \
-            -m ${datadir}/obmc-mrw/${MACHINE}.xml \
+            -m ${mrw_datadir}/${MRW_XML} \
             -o ${DEST}/callouts.yaml
 }
diff --git a/meta-phosphor/common/recipes-phosphor/mrw/mrw-native.bb b/meta-phosphor/common/recipes-phosphor/mrw/mrw-native.bb
index 12a9b9e..db9cbd9 100644
--- a/meta-phosphor/common/recipes-phosphor/mrw/mrw-native.bb
+++ b/meta-phosphor/common/recipes-phosphor/mrw/mrw-native.bb
@@ -7,13 +7,14 @@
 inherit obmc-phosphor-license
 inherit obmc-xmlpatch
 inherit native
+inherit mrw-xml
 
 PHOSPHOR_MRW_URI ?= "http://missing-mrw-uri"
 SRC_URI += "${PHOSPHOR_MRW_URI}"
 SRCREV = "${PHOSPHOR_MRW_REV}"
 
 do_install() {
-    install -d ${D}${datadir}/obmc-mrw
-    install -m 0644 ${MACHINE}.xml ${D}${datadir}/obmc-mrw
+    install -d ${D}/${mrw_datadir}
+    install -m 0644 ${MRW_XML} ${D}/${mrw_datadir}
 }
 
diff --git a/meta-phosphor/common/recipes-phosphor/sensors/phosphor-hwmon-config-mrw.bb b/meta-phosphor/common/recipes-phosphor/sensors/phosphor-hwmon-config-mrw.bb
index 7e016b5..c6d0cba 100644
--- a/meta-phosphor/common/recipes-phosphor/sensors/phosphor-hwmon-config-mrw.bb
+++ b/meta-phosphor/common/recipes-phosphor/sensors/phosphor-hwmon-config-mrw.bb
@@ -4,13 +4,14 @@
 
 inherit obmc-phosphor-license
 inherit allarch
+inherit mrw-xml
 
 DEPENDS += "mrw-perl-tools-native mrw-native"
 
 do_compile_append() {
     ${STAGING_BINDIR_NATIVE}/perl-native/perl \
         ${STAGING_BINDIR_NATIVE}/hwmon.pl \
-        -x ${STAGING_DATADIR_NATIVE}/obmc-mrw/${MACHINE}.xml \
+        -x ${mrw_datadir}/${MRW_XML} \
         -d ${WORKDIR}/mrw-config-files
 }
 
diff --git a/meta-phosphor/common/recipes-phosphor/settings/phosphor-settings-read-settings-mrw.bb b/meta-phosphor/common/recipes-phosphor/settings/phosphor-settings-read-settings-mrw.bb
index 7260434..2080a3b 100644
--- a/meta-phosphor/common/recipes-phosphor/settings/phosphor-settings-read-settings-mrw.bb
+++ b/meta-phosphor/common/recipes-phosphor/settings/phosphor-settings-read-settings-mrw.bb
@@ -7,6 +7,7 @@
 
 inherit native
 inherit phosphor-settings-manager
+inherit mrw-xml
 
 inherit obmc-phosphor-license
 
@@ -26,7 +27,7 @@
     # gen_settings.pl replaces any MRW variables with their value
     ${bindir}/perl-native/perl \
         ${bindir}/gen_settings.pl \
-        -i ${datadir}/obmc-mrw/${MACHINE}.xml \
+        -i ${mrw_datadir}/${MRW_XML} \
         -s ${DEST}/mrw-override-settings.yaml \
         -o ${SETTINGS}/mrw-settings.override.yaml \
         -f