From b3061a182421ca07f0b5d0b0a7b14a0894c35cb3 Mon Sep 17 00:00:00 2001 From: Junhwan Park Date: Wed, 19 Apr 2017 12:58:08 +0900 Subject: [PATCH] builtin: add tash builtin application The existing tizenRT was made by tash_cmd_install command each time the application was registered. When you apply this patch, menuconfig will be able to register to tash as soon as you select it. However, when the developer registers an application, the following format should be added in the Makefile. $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile $(call REGISTER,$(APPNAME),$(APPNAME)_main,$(THREADEXEC)) context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat Change-Id: I09e77e608e3dfeac5e14c7222105ae3404fd0039 Signed-off-by: Junhwan Park --- apps/Make.defs | 22 ++++++ apps/builtin/.gitignore | 11 +++ apps/builtin/Make.defs | 57 ++++++++++++++ apps/builtin/Makefile | 157 +++++++++++++++++++++++++++++++++++++++ apps/builtin/builtin_list.c | 97 ++++++++++++++++++++++++ apps/builtin/registry/.gitignore | 5 ++ apps/builtin/registry/Makefile | 80 ++++++++++++++++++++ apps/system/init/init.c | 2 + 8 files changed, 431 insertions(+) create mode 100644 apps/builtin/.gitignore create mode 100644 apps/builtin/Make.defs create mode 100644 apps/builtin/Makefile create mode 100644 apps/builtin/builtin_list.c create mode 100644 apps/builtin/registry/.gitignore create mode 100644 apps/builtin/registry/Makefile diff --git a/apps/Make.defs b/apps/Make.defs index 7c974a1..4f2d9f5 100644 --- a/apps/Make.defs +++ b/apps/Make.defs @@ -51,6 +51,28 @@ # ############################################################################ +# Builtin Registration + +BUILTIN_REGISTRY = $(APPDIR)$(DELIM)builtin$(DELIM)registry + +DEPCONFIG = $(TOPDIR)$(DELIM).config + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) +define REGISTER + $(Q) echo Register: $1 + $(Q) echo { "$1", $2, $3 }, > "$(BUILTIN_REGISTRY)$(DELIM)$2.bdat" + $(Q) echo int $2(int argc, char *argv[]); > "$(BUILTIN_REGISTRY)$(DELIM)$2.pdat" + $(Q) touch $(BUILTIN_REGISTRY)$(DELIM).updated" +endef +else +define REGISTER + $(Q) echo "Register: $1" + $(Q) echo "{ \"$1\", $2, $3 }," > "$(BUILTIN_REGISTRY)$(DELIM)$2.bdat" + $(Q) echo "int $2(int argc, char *argv[]);" > "$(BUILTIN_REGISTRY)$(DELIM)$2.pdat" + $(Q) touch "$(BUILTIN_REGISTRY)$(DELIM).updated" +endef +endif + # Tools ifeq ($(CONFIG_WINDOWS_NATIVE),y) diff --git a/apps/builtin/.gitignore b/apps/builtin/.gitignore new file mode 100644 index 0000000..8ccdce2 --- /dev/null +++ b/apps/builtin/.gitignore @@ -0,0 +1,11 @@ +/.context +/.depend +/.built +/Make.dep +/builtin_list.h +/builtin_proto.h +/*.src +/*.obj +/*.lst +/*.asm +/*.sym diff --git a/apps/builtin/Make.defs b/apps/builtin/Make.defs new file mode 100644 index 0000000..1208bb7 --- /dev/null +++ b/apps/builtin/Make.defs @@ -0,0 +1,57 @@ +########################################################################### +# +# Copyright 2017 Samsung Electronics All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +# +########################################################################### +############################################################################ +# apps/builtin/Make.defs +# Adds selected applications to apps/ build +# +# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifeq ($(CONFIG_TASH),y) +CONFIGURED_APPS += builtin +endif + diff --git a/apps/builtin/Makefile b/apps/builtin/Makefile new file mode 100644 index 0000000..e646a27 --- /dev/null +++ b/apps/builtin/Makefile @@ -0,0 +1,157 @@ +########################################################################### +# +# Copyright 2016 Samsung Electronics All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +# +########################################################################### +############################################################################ +# apps/builtin/Makefile +# +# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +# Source and object files + +ASRCS = +CSRCS = builtin_list.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\libapps$(LIBEXT) +else +ifeq ($(WINTOOL),y) + BIN = ..\\libapps$(LIBEXT) +else + BIN = ../libapps$(LIBEXT) +endif +endif + +ROOTDEPPATH = --dep-path . +VPATH = + +# Build Targets + +all: .built +.PHONY: context depend clean distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +registry$(DELIM).updated: + $(Q) $(MAKE) -C registry .updated TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" + +builtin_list$(OBJEXT): builtin_list.h builtin_proto.h + +builtin_list.h: registry$(DELIM).updated + $(call DELFILE, .xx_builtin_list.h) + $(Q) touch .xx_builtin_list.h +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + $(Q) (for /f %%G in ('dir /b registry\*.bdat') do ( type registry\%%G >> .xx_builtin_list.h )) || echo "" +else + $(Q) ( \ + filelist=`ls registry/*.bdat 2>/dev/null || echo ""`; \ + for file in $$filelist; \ + do cat $$file >> .xx_builtin_list.h; \ + done; \ + ) +endif + $(Q) mv .xx_builtin_list.h builtin_list.h + +builtin_proto.h: registry$(DELIM).updated + $(call DELFILE, .xx_builtin_proto.h) + $(Q) touch .xx_builtin_proto.h +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + $(Q) (for /f %%G in ('dir /b registry\*.pdat') do ( type registry\%%G >> .xx_builtin_proto.h )) || echo "" +else + $(Q) ( \ + filelist=`ls registry/*.pdat 2>/dev/null || echo ""`; \ + for file in $$filelist; \ + do cat $$file >> .xx_builtin_proto.h; \ + done; \ + ) +endif + $(Q) mv .xx_builtin_proto.h builtin_proto.h + +.built: $(OBJS) + $(call ARCHIVE, $(BIN), $(OBJS)) + $(Q) touch .built + +install: + +context: + $(Q) $(MAKE) -C registry context TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" + +.depend: Makefile $(SRCS) builtin_list.h builtin_proto.h + $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + $(Q) touch $@ + +depend: .depend + +clean: + $(Q) $(MAKE) -C registry clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" + $(call DELFILE, .built) + $(call DELFILE, .xx_builtin_list.h) + $(call DELFILE, .xx_builtin_proto.h) + $(call CLEAN) + +distclean: clean + $(Q) $(MAKE) -C registry distclean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + $(call DELFILE, builtin_list.h) + $(call DELFILE, builtin_proto.h) + +-include Make.dep +.PHONY: preconfig +preconfig: diff --git a/apps/builtin/builtin_list.c b/apps/builtin/builtin_list.c new file mode 100644 index 0000000..ffa90c3 --- /dev/null +++ b/apps/builtin/builtin_list.c @@ -0,0 +1,97 @@ +/**************************************************************************** + * + * Copyright 2016 Samsung Electronics All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + * + ****************************************************************************/ +/**************************************************************************** + * apps/builtin/builtin_list.c + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Authors: Uros Platise + * Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#include "builtin_proto.h" + +const static tash_cmdlist_t examples_cmds[] = { +#include "builtin_list.h" + { NULL, NULL, 0 } +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void register_examples_cmds(void) +{ + tash_cmdlist_install(examples_cmds); +} diff --git a/apps/builtin/registry/.gitignore b/apps/builtin/registry/.gitignore new file mode 100644 index 0000000..40b96fa --- /dev/null +++ b/apps/builtin/registry/.gitignore @@ -0,0 +1,5 @@ +.updated +*.pdat +*.bdat + + diff --git a/apps/builtin/registry/Makefile b/apps/builtin/registry/Makefile new file mode 100644 index 0000000..3c38cff --- /dev/null +++ b/apps/builtin/registry/Makefile @@ -0,0 +1,80 @@ +########################################################################### +# +# Copyright 2016 Samsung Electronics All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +# +########################################################################### +############################################################################ +# apps/builtin/registry/Makefile +# +# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +# NSH Library + +all: +.PHONY: context depend clean distclean + +.updated: $(DEPCONFIG) + $(call DELFILE, *.bdat) + $(call DELFILE, *.pdat) + $(Q) touch .updated + +# This must run before any other context target + +install: + +context: .updated + +depend: + +clean: + $(call CLEAN) + +distclean: clean + $(call DELFILE, *.bdat) + $(call DELFILE, *.pdat) + $(call DELFILE, .updated) diff --git a/apps/system/init/init.c b/apps/system/init/init.c index a5d0d69..56881a1 100644 --- a/apps/system/init/init.c +++ b/apps/system/init/init.c @@ -69,6 +69,8 @@ static void tash_register_cmds(void) net_register_utilcmds(); net_register_appcmds(); #endif + + register_examples_cmds(); } #endif /* CONFIG_TASH */ -- 2.7.4