xiaoxiang781216 commented on code in PR #3730:
URL: https://github.com/apache/nuttx-apps/pull/3730#discussion_r3793670318


##########
README.md:
##########
@@ -158,6 +158,33 @@ project. One must:
     endif
     ```
 
+## Example Shared Library

Review Comment:
   should we migrate README.md to nuttx/Documentation?



##########
Library.mk:
##########
@@ -0,0 +1,190 @@
+############################################################################
+# apps/Library.mk
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you 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.
+#
+############################################################################
+
+# Library.mk is the NuttX equivalent of Android's BUILD_SHARED_LIBRARY.  A
+# component Makefile includes Make.defs, declares LOCAL_MODULE and
+# LOCAL_SRC_FILES, then includes this file.  NuttX invokes each component in
+# a separate recursive make, so module variables cannot leak between
+# components and an equivalent of Android's CLEAR_VARS is not needed.
+
+LOCAL_PATH ?= $(CURDIR)
+
+ifeq ($(strip $(LOCAL_MODULE)),)
+  $(error LOCAL_MODULE must name the shared library)
+endif
+
+ifeq ($(strip $(LOCAL_SRC_FILES)),)
+  $(error LOCAL_SRC_FILES must list at least one C or C++ source file)
+endif
+
+LOCAL_C_SRCS   := $(filter %.c,$(LOCAL_SRC_FILES))
+LOCAL_CC_SRCS  := $(filter %.cc,$(LOCAL_SRC_FILES))
+LOCAL_CPP_SRCS := $(filter %.cpp,$(LOCAL_SRC_FILES))
+LOCAL_CXX_SRCS := $(filter %.cxx,$(LOCAL_SRC_FILES))
+LOCAL_SRCS     := $(LOCAL_C_SRCS) $(LOCAL_CC_SRCS) $(LOCAL_CPP_SRCS) \
+                  $(LOCAL_CXX_SRCS)
+
+ifneq ($(words $(LOCAL_SRCS)),$(words $(LOCAL_SRC_FILES)))
+  $(error LOCAL_SRC_FILES currently supports only .c, .cc, .cpp, and .cxx)
+endif
+
+# The GNU make CURDIR always uses forward slashes.  Convert it for native
+# Windows builds before deriving the suffix used for intermediate objects.
+
+ifeq ($(CONFIG_WINDOWS_NATIVE),y)
+  LOCAL_CWD := $(strip ${shell echo %CD% | cut -d: -f2})
+else
+  LOCAL_CWD := $(CURDIR)
+endif
+
+LOCAL_SUFFIX := $(subst $(DELIM),.,$(LOCAL_CWD))
+LOCAL_PREFIX ?=
+
+LOCAL_C_OBJS   := $(LOCAL_C_SRCS:%=$(LOCAL_PREFIX)%$(LOCAL_SUFFIX)$(OBJEXT))
+LOCAL_CC_OBJS  := $(LOCAL_CC_SRCS:%=$(LOCAL_PREFIX)%$(LOCAL_SUFFIX)$(OBJEXT))
+LOCAL_CPP_OBJS := $(LOCAL_CPP_SRCS:%=$(LOCAL_PREFIX)%$(LOCAL_SUFFIX)$(OBJEXT))
+LOCAL_CXX_OBJS := $(LOCAL_CXX_SRCS:%=$(LOCAL_PREFIX)%$(LOCAL_SUFFIX)$(OBJEXT))
+LOCAL_OBJS     := $(LOCAL_C_OBJS) $(LOCAL_CC_OBJS) $(LOCAL_CPP_OBJS) \
+                  $(LOCAL_CXX_OBJS)
+
+# Keep the historical NuttX module filename by default.  A component may set
+# LOCAL_MODULE_FILENAME (for example, libexample.so) when a suffix is part of
+# its external interface.
+
+LOCAL_MODULE_FILENAME ?= $(LOCAL_MODULE)
+LOCAL_MODULE_PATH     := $(BINDIR)$(DELIM)$(LOCAL_MODULE_FILENAME)
+
+LOCAL_CFLAGS   ?=
+LOCAL_CXXFLAGS ?=
+LOCAL_LDFLAGS  ?=
+LOCAL_LDLIBS   ?=
+
+LOCAL_COMPILER_RT_LIB := $(shell $(CC) $(ARCHCPUFLAGS) \

Review Comment:
   could we reuse some code snippet from Make.defs/Application.mk?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to