《cmake调用shell》
来源:互联网 发布:柯洁人工智能 编辑:程序博客网 时间:2024/06/17 01:31
1. CMakeLists.txt
add_custom_target(config ALL COMMAND bash x.sh )
2. shell
########################################################################## File Name: x.sh# Author: XXDK# Created Time: Wed 01 Nov 2017 05:08:50 PM CST##########################################################################!/bin/bash# masking all out put info!set +x #-----------------------------------------------# function fprint()#-----------------------------------------------fprint() {#if [ 1 ] if [ ! 1 ] thenecho -n "Func: $FUNCNAME Line: $LINENO " && echo $1;fi}#-----------------------------------------------# global variable value#-----------------------------------------------exec_path=`pwd`;fprint "exec_path: $exec_path";config_file_path=`cd ../config_file; pwd`;fprint "config_file_path: $config_file_path";src_root_path=`cd ../; pwd`;fprint "src_root_path: $src_root_path";out_directory="$src_root_path/out";fprint "out_directory: $out_directory";config_file_list=`cd ../config_file; ls`;config_file_common='config_file_common.conf';out_dir_com_prefix='cleanna';config_file_count=0;#-----------------------------------------------# function total_config_file() #-----------------------------------------------clean_out_directory(){if [ -d ../out ]thenrm ../out -rf;fi}#-----------------------------------------------# function total_config_file() #-----------------------------------------------total_config_file() {for file in $config_file_listdoif [ -f $1/$file ]then config_file_count=`expr $config_file_count + 1`;fprint $file;fidone return $config_file_count;}#-----------------------------------------------# function check_file_exist() #-----------------------------------------------check_file_exist() {if [ -f $1 ]thenfprint "get $1";return 1;else fprint "no $1";return 0;fi}#-----------------------------------------------# function create_out_directory() #-----------------------------------------------create_out_directory() {if [ ! -d $1 ]thenmkdir $1;fprint "create $1 success!";return 1;else fprint "$1 already exist!";return 0;fi}#-----------------------------------------------# function process_config_file()#-----------------------------------------------process_config_file() {local target_dir=$1;if [ ! -d "$target_dir/app" ] # out/cleannaXXXX/appthen mkdir "$target_dir/app";touch "$target_dir/app/config_file.conf"; #out/cleannaXXXX/app/config_file.confcat "$config_file_path/$config_file_common" > "$target_dir/app/config_file.conf";cat "$config_file_path/$file" >> "$target_dir/app/config_file.conf";return 1;else fprint "$target_dir/app already exist!";return 0;fi}#-----------------------------------------------# function process_bootauto_file()#-----------------------------------------------process_bootauto_file() {local target_dir=$1;if [ ! -d "$target_dir/boot" ] # out/cleannaXXXX/bootthen mkdir "$target_dir/boot";check_file_exist "$config_file_path/boot/BootAuto.sh"if [ $? = 1 ] then #out/cleannaXXXX/boot/BootAuto.shcp "$config_file_path/boot/BootAuto.sh" "$target_dir/boot"; return 1;else fprint "check $config_file_path/boot/BootAuto.sh error";return 0;fielse fprint "$target_dir/boot/BootAuto.sh already exist!";return 0;fi}#-----------------------------------------------# function process_small_vex_file()#-----------------------------------------------process_small_vex_file() {local target_dir=$1;check_file_exist "$config_file_path/small_voc.txt.compressed"if [ $? = 1 ] then #out/cleannaXXXX/app/small_voc.txt.compressedcp "$config_file_path/small_voc.txt.compressed" "$target_dir/app"; return 1;else fprint "check $config_file_path/small_voc.txt.compressed error";return 0;fi}#-----------------------------------------------# function process_small_vex_file()#-----------------------------------------------process_sta_wifi_file() {local target_dir=$1check_file_exist "$config_file_path/boot/sta_wifi_common.sh"if [ $? = 1 ] then #out/cleannaXXXX/boot/sta_wifi.shcp "$config_file_path/boot/sta_wifi_common.sh" "$target_dir/boot/sta_wifi.sh"; return 1;else fprint "check $config_file_path/boot/sta_wifi_common.sh error";return 0;fi}#-----------------------------------------------# function print_out_directory() #-----------------------------------------------print_out_directory() {out_config_file_dir=`cd ../out; ls`;for dir in "$out_config_file_dir"do fprint $dir;done }#-----------------------------------------------# function main_task() #-----------------------------------------------main_task() {for file in $config_file_listdoif [ -f "$config_file_path/$file" ]then if [ ${file#*.} = "conf" ] #extract file which has ".conf" suffixthenfile_no_conf_suffix=${file%.*}; #discard suffix ".conf"fprint ${file_no_conf_suffix};file_no_cfc_prefix=${file_no_conf_suffix##*_}; #cfc confile_file_cleanna_fprint ${file_no_cfc_prefix};if [ ! -d "$out_directory""/""$out_dir_com_prefix""$file_no_cfc_prefix" ]then local target_dir="$out_directory""/""$out_dir_com_prefix""$file_no_cfc_prefix"; # out/cleannaXXXX/mkdir $target_dir; # out/cleannaXXXX/# 1. config_file process_config_file $target_dir;if [ $? = 1 ]; then fprint "process config file success!";else fprint "process config file failed!";fi# 2. boot process_bootauto_file $target_dir;if [ $? = 1 ]; then fprint "process bootauto file success!";else fprint "process bootauto file failed!";fi# 3. small_vocprocess_small_vex_file $target_dir;if [ $? = 1 ]; then fprint "process small_voc file success!";else fprint "process small_voc file failed!";fi# 4. sta_wifiprocess_sta_wifi_file $target_dir;if [ $? = 1 ]; then fprint "process sta_wifi file success!";else fprint "process sta_wifi file failed!";fielse fprint ""$out_directory""/""$out_dir_com_prefix""$file_no_cfc_prefix" already exist!";return 0;fificonfig_file_count=`expr $config_file_count + 1`;fprint $file;fidone return 1;}#-----------------------------------------------# function main() #-----------------------------------------------main() {# 1.---------------------------------------clean_out_directory;# 2.---------------------------------------total_config_file $config_file_path;if [ $? = 0 ]; then fprint "no config file to process!";else fprint "total config file: $? ";fi# 3.---------------------------------------check_file_exist "$config_file_path/$config_file_common" if [ $? = 1 ]; then fprint "config_file_common.sh check pass!";else fprint "can't find config_file_common.sh";fi# 4.---------------------------------------create_out_directory "$out_directory";if [ $? = 1 ]; then fprint "Create roboserver/out directory ok";else fprint "Create roboserver/out directory error";fi# 5.---------------------------------------main_task;}#-----------------------------------------------# running extry main#-----------------------------------------------#set +xwhile truedo main;break;done set -x
阅读全文
0 0
- CMake 调用 Shell 脚本
- CMake调用shell脚步
- 《cmake调用shell》
- CMake 执行shell
- CMake调用OpenMP
- CMake如何执行shell命令
- shell中调用shell
- android studio cmake调用ffmpeg库
- CMake调用多个C文件
- CMake再探:引入SO文件并调用
- shell 中调用另一个 shell
- perl调用shell shell调用perl
- c++调用shell & shell调用python
- shell学习之-shell调用shell
- cmake
- cMAKE
- cmake
- CMake
- JTable单元格文字实现自动换行
- Web基础
- 字符串函数【C++】
- 【Unity Shader入门精要】— 透明效果
- python爬虫 -- scrapy框架
- 《cmake调用shell》
- caltech pedestrian detection数据集格式转换
- 深入理解Java类型信息(Class对象)与反射机制
- 网站被黑,到底是谁的责任?
- DataOutputStream和ObjectOutputStream在用法上有什么区别?
- MATLAB基础教程(2) 语言基础知识
- nginx中文文档、nginx在Windows,linux下启动和停止等命令
- CC2530中的源地址匹配
- 贪心:区间相交问题