mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 17:31:13 +03:00
contributions.md: Updated sensortemplate script
C/C++ CMakeLists.txt lines are no longer needed - removed. Converted bash script to a function to add some error checking. Removed redundant author/copyright entry. Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
@ -105,27 +105,42 @@ commands below to generate collateral files for your new sensor library.
|
||||
|
||||
|
||||
```shell
|
||||
# Set SensorName to your new library name, example: 'MyNewSensor1234'
|
||||
export SensorName=MyNewSensor1234
|
||||
#!/bin/bash
|
||||
|
||||
# Copy/paste the below commands into a bash shell...
|
||||
# Get a lowercase version of the string
|
||||
export sensorname=${SensorName,,}
|
||||
# Copy sensortemplate files to ${sensorname}
|
||||
find docs/ examples/ src/ -name '*sensortemplate*' -exec bash -c 'cp -r $0 ${0/sensortemplate/${sensorname}}' {} \;
|
||||
# Copy SensorTemplate files to ${SensorName}
|
||||
find examples/ src/ -name '*SensorTemplate*' -exec bash -c 'cp -r $0 ${0/SensorTemplate/${SensorName}}' {} \;
|
||||
# Rename sernsortemplate src files
|
||||
rename "s/sensortemplate/${sensorname}/" src/${sensorname}/*
|
||||
# Search/replace the new files, replacing all instances of sensortemplate
|
||||
perl -p -i -e "s/SensorTemplate/${SensorName}/g" src/${sensorname}/* examples/*/*${sensorname}* examples/*/*${SensorName}*
|
||||
perl -p -i -e "s/sensortemplate/${sensorname}/g" src/${sensorname}/* examples/*/*${sensorname}* examples/*/*${SensorName}*
|
||||
# Add mynewmodule example target for c++
|
||||
perl -p -i -e "s/^((.*)sensortemplate(.*))/\1\n\2${sensorname}\3/g" examples/c++/CMakeLists.txt
|
||||
# Add mynewmodule example target for java
|
||||
perl -p -i -e "s/^((.*)SensorTemplateSample sensortemplate(.*))/\1\n\2${SensorName}Sample ${sensorname}\3/g" examples/java/CMakeLists.txt
|
||||
# Add mynewmodule example mappings for doxygen
|
||||
perl -p -i -e "s/^(.*SensorTemplateSample.*)$/\1\n${sensorname}.cxx\t${SensorName}Sample.java\t${sensorname}.js\t${sensorname}.py/g" doxy/samples.mapping.txt
|
||||
function make_new_sensor {
|
||||
SensorName=$1
|
||||
# Make sure this is run from the root UPM directory
|
||||
if ! grep -q 'UPM ' README.md; then echo "Please run from the root UPM directory"; return -1; fi
|
||||
|
||||
# Copy/paste the below commands into a bash shell...
|
||||
# Get a lowercase version of the string
|
||||
sensorname=${SensorName,,}
|
||||
# Copy sensortemplate files to ${sensorname}
|
||||
find docs/ examples/ src/ -name '*sensortemplate*' -exec bash -c 'cp -r $0 ${0/sensortemplate/${sensorname}}' {} \;
|
||||
# Copy SensorTemplate files to ${SensorName}
|
||||
find examples/ src/ -name '*SensorTemplate*' -exec bash -c 'cp -r $0 ${0/SensorTemplate/${SensorName}}' {} \;
|
||||
# Rename sernsortemplate src files
|
||||
rename "s/sensortemplate/${sensorname}/" src/${sensorname}/*
|
||||
# Search/replace the new files, replacing all instances of sensortemplate
|
||||
perl -p -i -e "s/SensorTemplate/${SensorName}/g" src/${sensorname}/* examples/*/*${sensorname}* examples/*/*${SensorName}*
|
||||
perl -p -i -e "s/sensortemplate/${sensorname}/g" src/${sensorname}/* examples/*/*${sensorname}* examples/*/*${SensorName}*
|
||||
# Add mynewmodule example target for java
|
||||
perl -p -i -e "s/^((.*)SensorTemplateSample sensortemplate(.*))/\1\n\2${SensorName}Sample ${sensorname}\3/g" examples/java/CMakeLists.txt
|
||||
# Add mynewmodule example mappings for doxygen
|
||||
perl -p -i -e "s/^(.*SensorTemplateSample.*)$/\1\n${sensorname}.cxx\t${SensorName}Sample.java\t${sensorname}.js\t${sensorname}.py/g" doxy/samples.mapping.txt
|
||||
# Display TODO's
|
||||
printf "Generation complete for sensor library: ${SensorName}\n"
|
||||
printf "TODO's:\n"
|
||||
printf "\t1. Update src/hdr files: src/${sensorname}/${sensorname}.hpp src/${sensorname}/${sensorname}.cxx\n"
|
||||
printf "\t\tChange the Author\n"
|
||||
printf "\t\tChange the Copyright\n"
|
||||
printf "\t\tUpdate all doxygen tags (follow directions for @tags)\n"
|
||||
printf "\t2. Update examples: examples/*/${sensorname}.* examples/java/*${SensorName}*.java\n"
|
||||
printf "\t3. Overwrite docs/images/${sensorname}.png with a valid image of your sensor\n"
|
||||
}
|
||||
|
||||
# Call make_new_sensor with your new sensor name, example: 'MyNewSensor1234'
|
||||
make_new_sensor MyNewSensor1234
|
||||
```
|
||||
|
||||
Once all files have been created, they can be used as a starting-point for your
|
||||
|
Reference in New Issue
Block a user