From 3c5d00285b4cf1516790188b540013f3f5f1aa3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=95?= Date: Mon, 17 Jun 2019 17:05:32 +0800 Subject: [PATCH] =?UTF-8?q?Mod=20=20aaa-12=20=20=E6=9B=B4=E6=96=B0demo?= =?UTF-8?q?=E5=B7=A5=E7=A8=8B=20RCA=EF=BC=9A=20SOL=EF=BC=9A=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=BA=EF=BC=9Ahuangxin=20=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E4=BA=BA=EF=BC=9Ahuangxin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Common/common.Makefile | 1 + Makefile | 8 +++--- Product/build/user.demo.Makefile | 14 +++++++---- Product/user/demo/main.c | 42 +++++++++++++++++++++++++++++--- 4 files changed, 54 insertions(+), 11 deletions(-) diff --git a/Common/common.Makefile b/Common/common.Makefile index b96b038e9..bde7f8e12 100755 --- a/Common/common.Makefile +++ b/Common/common.Makefile @@ -370,6 +370,7 @@ PLAT_LINUX_OBJS := PLAT_LINUX_DEPS := endif +$(info objects:[$(PLAT_LINUX_OBJS)]) # 构建系统最终需要生成的目标,包含 ARM64 和 Linux 平台 ALL_OBJS += $(PLAT_ARM64_OBJS) $(PLAT_LINUX_OBJS) ALL_DEPS += $(PLAT_ARM64_DEPS) $(PLAT_LINUX_DEPS) diff --git a/Makefile b/Makefile index 8a35bfb4c..18f21a346 100755 --- a/Makefile +++ b/Makefile @@ -33,15 +33,17 @@ endif all: demo conntrack netlink trace ifeq ($(OPT), install) -#$(shell `find ../release -name "*.zip" -delete`) +#$(shell `find ../release -name "*.zip" -delete`) +else ifeq ($(OPT), clean) +# +else +$(shell chmod +x ./build_env.sh && ./build_env.sh) endif ifeq ($(OPT), clean) # endif -$(shell chmod +x ./build_env.sh) -$(shell test -e ./Common/compile.h || ./build_env.sh) demo: ifeq ($(OPT), clean) diff --git a/Product/build/user.demo.Makefile b/Product/build/user.demo.Makefile index 9762be3c2..9a76268b0 100755 --- a/Product/build/user.demo.Makefile +++ b/Product/build/user.demo.Makefile @@ -21,18 +21,22 @@ DEBUG = TRUE PLAT_LINUX ?= TRUE PLAT_ARM64 ?= TRUE -VPATH = ../user/demo +SRC_DIR = ../user/demo + +VPATH = $(SRC_DIR) # source code # set the source file, don't used .o because of ... -# MRS Board Source Files -PLAT_LINUX_SRCS := main.c version.c +# Linux Board Source Files +PLAT_LINUX_SRCS := $(subst $(SRC_DIR)/, , $(wildcard $(SRC_DIR)/*.c)) +#main.c version.c PLAT_ARM64_SRCS := $(PLAT_LINUX_SRCS) # gcc CFLAGS -PLAT_LINUX_CFLAGS += -DVERSION=\"v0.0.0.1\" -PLAT_ARM64_CFLAGS += -DVERSION=\"v0.0.0.1\" +COMMON_CFLAGS := -I../../Common +PLAT_LINUX_CFLAGS += $(COMMON_CFLAGS) +PLAT_ARM64_CFLAGS += $(COMMON_CFLAGS) # this line must be at below of thus, because of... include ../../Common/common.Makefile diff --git a/Product/user/demo/main.c b/Product/user/demo/main.c index c504a1897..60e11bbd4 100755 --- a/Product/user/demo/main.c +++ b/Product/user/demo/main.c @@ -1,9 +1,45 @@ #include +#include +#include -extern const char* get_version(void); +#include "compile.h" +/** + * @brief 应用程序主函数 + * @note + * @param argc: 输入参数个数 + * @param **argv: 输入参数详细内容 + * @retval 0 + */ int main(int argc, char **argv) { - fprintf(stdout, "Hello vBRAS Product user demo version: %ld\n", get_version()); - return 0; + int c, optidx = 0; + opterr = 0; + static struct option long_opts[] = { + { "help", 0, 0, 'h' }, + { "version", 0, 0, 'v' }, + // TODO 添加其它需要处理的参数配置 + { 0, 0, 0, 0 } + }; + + while((c = getopt_long(argc, argv, "hv", long_opts, &optidx)) != -1) + { + switch (c) + { + case 'v': + fprintf(stdout, "User demo version: %s(%s)\n", sGATE_GIT_TAGS, sGATE_GIT_VERS); + break; + //TODO 添加其它必要处理参数过程 + + case '?': + case 'h': + fprintf(stdout, "Usage: %s [-h] [-v] ...\n", argv[0]); + fprintf(stdout, "options:\n"); + fprintf(stdout, "\t-v, --version show program version\n"); + fprintf(stdout, "\t-h, --help print this message\n"); + break; + } + } + + return 0; }