Blame view

trunk/auto/apps.sh 2.6 KB
1 2
# generate the binary
#
winlin authored
3
# params:
4 5
#     $SRS_OBJS the objs directory to store the Makefile. ie. ./objs
#     $SRS_OBJS_DIR the objs directory for Makefile. ie. objs
6 7 8 9 10 11 12 13 14
#     $SRS_MAKEFILE the makefile name. ie. Makefile
#
#     $MAIN_ENTRANCES array, disable all except the $APP_MAIN itself. ie. ["srs_main_server" "srs_main_bandcheck"]
#     $APP_MAIN the object file that contains main function. ie. srs_main_server
#     $BUILD_KEY a string indicates the build key for Makefile. ie. srs
#     $APP_NAME the app name to output. ie. srs
#     $MODULE_OBJS array, the objects to compile the app.
#     $ModuleLibFiles array, the 3rdpart library file to link with. ie. [objs/st-1.9/obj/libst.a objs/libx264/obj/libx264.a]
#     $LINK_OPTIONS the linker options. ie. -ldl
winlin authored
15
16
FILE=${SRS_OBJS}/${SRS_MAKEFILE}
winlin authored
17
18
APP_TARGET="${SRS_OBJS_DIR}/${APP_NAME}"
winlin authored
19 20 21 22

echo "generate app ${APP_NAME} depends...";

echo "# build ${APP_TARGET}" >> ${FILE}
23 24
# generate the binary depends, for example:
#       srs: objs/srs
winlin authored
25
echo "${BUILD_KEY}: ${APP_TARGET}" >> ${FILE}
26 27
# the link commands, for example:
#       objs/srs: objs/src/core/srs_core.o
winlin authored
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
echo -n "${APP_TARGET}: " >> ${FILE}
for item in ${MODULE_OBJS[*]}; do
    FILE_NAME=`basename $item`
    FILE_NAME=${FILE_NAME%.*}
    
    ignored=0
    for disabled_item in ${MAIN_ENTRANCES[*]}; do
        if [[ ${FILE_NAME} == ${disabled_item} && ${FILE_NAME} != ${APP_MAIN} ]]; then
            ignored=1
            continue;
        fi
    done
    
    if [ ! -f ${item} ]; then
        ignored=1
    fi
    
    if [ ${ignored} == 1 ]; then
        continue;
    fi
    
49
    OBJ_FILE=${SRS_OBJS_DIR}/$item
winlin authored
50 51 52 53 54 55 56
    OBJ_FILE="${OBJ_FILE%.*}.o"
    echo -n "${OBJ_FILE} " >> ${FILE}
done
echo "" >> ${FILE}

echo "generate app ${APP_NAME} link...";
57 58 59
# genereate the actual link command, for example:
#       	$(LINK)  -o objs/srs objs/src/core/srs_core.o -ldl
echo -n "	\$(LINK) -o ${APP_TARGET} " >> ${FILE}
winlin authored
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
for item in ${MODULE_OBJS[*]}; do
    FILE_NAME=`basename $item`
    FILE_NAME=${FILE_NAME%.*}
    
    ignored=0
    for disabled_item in ${MAIN_ENTRANCES[*]}; do
        if [[ ${FILE_NAME} == ${disabled_item} && ${FILE_NAME} != ${APP_MAIN} ]]; then
            ignored=1
            continue;
        fi
    done
    
    if [ ! -f ${item} ]; then
        ignored=1
    fi
    
    if [ ${ignored} == 1 ]; then
        continue;
    fi
    
80
    OBJ_FILE=${SRS_OBJS_DIR}/$item
winlin authored
81 82 83 84 85 86 87 88 89 90 91 92
    OBJ_FILE="${OBJ_FILE%.*}.o"
    echo -n "${OBJ_FILE} " >> ${FILE}
done
# 3rdpart library static link.
for item in ${ModuleLibFiles[*]}; do
    echo -n "$item " >> ${FILE}
done
# link options.
echo -n "${LINK_OPTIONS}" >> ${FILE}
echo "" >> ${FILE}

echo -n "generate app ${APP_NAME} ok"; echo '!';