#34 The script to generate the new module template

SkyEye-1.3.4
open
xiaoqiao shu
5
2012-12-05
2011-11-18
kangsh
No

#Makefile.mod
#MODULE_NAME=$()
#SOURCE=
# Create Makefile.mod
#lib${MODULE_NAME}_la_SOURCES = $(SOURCE)
#lib${MODULE_NAME}_la_LDFLAGS = -module
MODULE_NAME=$1
echo $MODULE_NAME
mkdir $MODULE_NAME
MODULE_HEADER=${MODULE_NAME}/${MODULE_NAME}.h
touch ${MODULE_HEADER}
touch ${MODULE_NAME}/${MODULE_NAME}.c
touch ${MODULE_NAME}/${MODULE_NAME}_module.c

# Create the header file for device
echo "/* Autogenerated by SkyEye script */" >> ${MODULE_HEADER}
echo "#ifndef __${MODULE_NAME}_H__" >> ${MODULE_HEADER}
echo "#define __${MODULE_NAME}_H__" >> ${MODULE_HEADER}
echo "typedef struct ${MODULE_NAME}_reg{" >> ${MODULE_HEADER}
echo "}${MODULE_NAME}_reg_t;" >> ${MODULE_HEADER}
echo "typedef struct ${MODULE_NAME}_device{" >> ${MODULE_HEADER}
echo "\tconf_object_t* obj;" >> ${MODULE_HEADER}
echo "\t${MODULE_NAME}_reg_t* regs;" >> ${MODULE_HEADER}
echo "}${MODULE_NAME}_device;" >> ${MODULE_HEADER}
echo "#endif" >> ${MODULE_HEADER}

# Create the source code of module definition file
echo "#include <skyeye_module.h>" >> ${MODULE_FILE}
echo "extern void init_${MODULE_HEADER}();" >> ${MODULE_FILE}
echo "void module_init(){" >> ${MODULE_FILE}
echo "\tinit_${MODULE_HEADER}();" >> ${MODULE_FILE}
echo "}" >> ${MODULE_FILE}
echo "void module_fini(){" >> ${MODULE_FILE}
echo "}" >> ${MODULE_FILE}

# Create source code of device implementation

Discussion