From 52879b0b0434145dc1b2f859ca61edaeaf2f0da6 Mon Sep 17 00:00:00 2001 From: Noel Eck Date: Mon, 3 Apr 2017 15:03:53 -0700 Subject: [PATCH] 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 --- docs/contributions.md | 55 ++++++++++++++++--------- examples/c++/sensortemplate.cxx | 3 -- examples/java/SensorTemplateSample.java | 3 -- examples/javascript/sensortemplate.js | 3 -- examples/python/sensortemplate.py | 3 -- src/sensortemplate/sensortemplate.cxx | 3 -- src/sensortemplate/sensortemplate.hpp | 3 -- 7 files changed, 35 insertions(+), 38 deletions(-) diff --git a/docs/contributions.md b/docs/contributions.md index ba43b608..ce049c6f 100644 --- a/docs/contributions.md +++ b/docs/contributions.md @@ -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 diff --git a/examples/c++/sensortemplate.cxx b/examples/c++/sensortemplate.cxx index 98ba3a97..8d1ad221 100644 --- a/examples/c++/sensortemplate.cxx +++ b/examples/c++/sensortemplate.cxx @@ -4,9 +4,6 @@ * Author: Your Full Name * Copyright (c) * - * Author: - * Copyright (c) - * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to diff --git a/examples/java/SensorTemplateSample.java b/examples/java/SensorTemplateSample.java index 050eef9e..82590318 100644 --- a/examples/java/SensorTemplateSample.java +++ b/examples/java/SensorTemplateSample.java @@ -4,9 +4,6 @@ * Author: Your Full Name * Copyright (c) * - * Author: - * Copyright (c) - * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to diff --git a/examples/javascript/sensortemplate.js b/examples/javascript/sensortemplate.js index 67fa0bcb..53e02fe6 100644 --- a/examples/javascript/sensortemplate.js +++ b/examples/javascript/sensortemplate.js @@ -4,9 +4,6 @@ * Author: Your Full Name * Copyright (c) * - * Author: - * Copyright (c) - * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to diff --git a/examples/python/sensortemplate.py b/examples/python/sensortemplate.py index 237f8977..7b506547 100755 --- a/examples/python/sensortemplate.py +++ b/examples/python/sensortemplate.py @@ -3,9 +3,6 @@ # Author: Your Full Name # Copyright (c) # -# Author: -# Copyright (c) -# # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to diff --git a/src/sensortemplate/sensortemplate.cxx b/src/sensortemplate/sensortemplate.cxx index 6c9f9cb4..fb3bda2a 100644 --- a/src/sensortemplate/sensortemplate.cxx +++ b/src/sensortemplate/sensortemplate.cxx @@ -4,9 +4,6 @@ * Author: Your Full Name * Copyright (c) * - * Author: - * Copyright (c) - * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to diff --git a/src/sensortemplate/sensortemplate.hpp b/src/sensortemplate/sensortemplate.hpp index 8d466633..b5fff190 100644 --- a/src/sensortemplate/sensortemplate.hpp +++ b/src/sensortemplate/sensortemplate.hpp @@ -4,9 +4,6 @@ * Author: Your Full Name * Copyright (c) * - * Author: - * Copyright (c) - * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to