Skip to content

Commit

Permalink
libxx: All cxx libraries move down one level
Browse files Browse the repository at this point in the history
Since there are some patches that need to be loaded manually, the original method is rather confusing. Now these patches that need to be loaded manually are classified into various cxx library folders, and each dynamically downloaded cxx library is moved down one directory to make the directory structure clearer.

Signed-off-by: wangmingrong1 <[email protected]>
  • Loading branch information
W-M-R authored and xiaoxiang781216 committed Nov 7, 2024
1 parent 6611480 commit db31e56
Show file tree
Hide file tree
Showing 28 changed files with 483 additions and 490 deletions.
10 changes: 2 additions & 8 deletions libs/libxx/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
/uClibc++
/libcxx
/libcxxabi
/libcxx-*.src.tar.xz
/libcxxabi-*.src.tar.xz
/etl
/.libcxx_patch
/.libcxxabi_patch
*.xz
*.bz2
14 changes: 1 addition & 13 deletions libs/libxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,4 @@
# the configuration problem. Refer to the README.txt file in the NuttX uClibc++
# GIT repository for more information

if(CONFIG_HAVE_CXX)
if(CONFIG_UCLIBCXX)
include(uClibc++.cmake)
elseif(CONFIG_LIBCXX)
include(libcxx.cmake)
elseif(CONFIG_LIBCXXMINI)
include(libcxxmini.cmake)
endif()

if(CONFIG_LIBCXXABI)
include(libcxxabi.cmake)
endif()
endif()
nuttx_add_subdirectory()
10 changes: 5 additions & 5 deletions libs/libxx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ include $(TOPDIR)/Make.defs
# in the NuttX uClibc++ GIT repository for more information

ifeq ($(CONFIG_UCLIBCXX),y)
include uClibc++.defs
include uClibc++/Make.defs
else ifeq ($(CONFIG_LIBCXX),y)
include libcxx.defs
include libcxx/Make.defs
else ifeq ($(CONFIG_LIBCXXMINI),y)
include libcxxmini.defs
include libcxxmini/Make.defs
endif

ifeq ($(CONFIG_ETL),y)
include etl.defs
include etl/Make.defs
endif

ifeq ($(CONFIG_LIBCXXABI),y)
include libcxxabi.defs
include libcxxabi/Make.defs
endif

# Object Files
Expand Down
32 changes: 15 additions & 17 deletions libs/libxx/etl.defs → libs/libxx/etl/Make.defs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
############################################################################
# libs/libxx/etl.defs
# libs/libxx/etl/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
Expand All @@ -23,34 +23,32 @@
ETL_VERSION=20.32.1

# Download and unpack tarball if no git repo found
ifeq ($(wildcard etl/.git),)
ifeq ($(wildcard etl/etl/.git),)
$(ETL_VERSION).tar.gz:
$(call DOWNLOAD,https://github.com/ETLCPP/etl/archive/refs/tags,$(ETL_VERSION).tar.gz)
$(call DOWNLOAD,https://github.com/ETLCPP/etl/archive/refs/tags,$@)

etl: $(ETL_VERSION).tar.gz
$(Q) tar -xf $(ETL_VERSION).tar.gz
$(Q) $(DELFILE) $(ETL_VERSION).tar.gz
$(Q) mv etl-$(ETL_VERSION) etl
$(Q) touch $@
etl/etl: $(ETL_VERSION).tar.gz
$(Q) tar -xf $<
$(Q) $(DELFILE) $<
$(Q) mv etl-$(ETL_VERSION) $@
endif

$(TOPDIR)/include/etl: etl
$(Q) $(DIRLINK) $(CURDIR)/etl/include $(TOPDIR)/include/etl
$(TOPDIR)/include/etl: etl/etl
$(Q) $(DIRLINK) $(CURDIR)/$</include $(TOPDIR)/include/etl
ifeq ($(CONFIG_ARCH_ARMV5M), y)
$(Q) cp $(CURDIR)/etl/include/etl/profiles/armv5_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
$(Q) cp $(CURDIR)/$</include/etl/profiles/armv5_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
else ifeq ($(CONFIG_ARCH_ARMV6M), y)
$(Q) cp $(CURDIR)/etl/include/etl/profiles/armv6_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
$(Q) cp $(CURDIR)/$</include/etl/profiles/armv6_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
else ifeq ($(CONFIG_ARCH_ARMV7M), y)
$(Q) cp $(CURDIR)/etl/include/etl/profiles/armv7_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
$(Q) cp $(CURDIR)/$</include/etl/profiles/armv7_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
else
$(Q) cp $(CURDIR)/etl/include/etl/profiles/gcc_generic_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
$(Q) cp $(CURDIR)/$</include/etl/profiles/gcc_generic_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
endif

context:: $(TOPDIR)/include/etl

distclean::
$(Q) $(DIRUNLINK) $(TOPDIR)/include/etl
ifeq ($(wildcard etl/.git),)
$(Q) $(DELFILE) $(ETL_VERSION).tar.gz
$(call DELDIR, etl)
ifeq ($(wildcard etl/etl/.git),)
$(call DELDIR, etl/etl)
endif
125 changes: 0 additions & 125 deletions libs/libxx/libcxx.cmake

This file was deleted.

1 change: 1 addition & 0 deletions libs/libxx/libcxx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/libcxx
File renamed without changes.
127 changes: 127 additions & 0 deletions libs/libxx/libcxx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# ##############################################################################
# libs/libxx/libcxx/CMakeLists.txt
#
# 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.
#
# ##############################################################################

if(CONFIG_LIBCXX)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libcxx)

set(LIBCXX_VERSION ${CONFIG_LIBCXX_VERSION})

FetchContent_Declare(
libcxx
DOWNLOAD_NAME "libcxx-${LIBCXX_VERSION}.src.tar.xz"
DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LIBCXX_VERSION}/libcxx-${LIBCXX_VERSION}.src.tar.xz"
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/libcxx
BINARY_DIR
${CMAKE_BINARY_DIR}/libs/libc/libcxx
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND
""
TEST_COMMAND
""
PATCH_COMMAND
patch -p1 -d ${CMAKE_CURRENT_LIST_DIR}/libcxx <
${CMAKE_CURRENT_LIST_DIR}/0001_fix_stdatomic_h_miss_typedef.patch &&
patch -p3 -d ${CMAKE_CURRENT_LIST_DIR}/libcxx <
${CMAKE_CURRENT_LIST_DIR}/mbstate_t.patch && patch -p1 -d
${CMAKE_CURRENT_LIST_DIR}/libcxx <
${CMAKE_CURRENT_LIST_DIR}/0001-libcxx-remove-mach-time-h.patch && patch
-p1 -d ${CMAKE_CURRENT_LIST_DIR}/libcxx <
${CMAKE_CURRENT_LIST_DIR}/0001-libcxx-fix-ld-errors.patch && patch -p1
-d ${CMAKE_CURRENT_LIST_DIR}/libcxx <
${CMAKE_CURRENT_LIST_DIR}/0001-Fix-build-error-about-__GLIBC__.patch
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)

FetchContent_GetProperties(libcxx)

if(NOT libcxx_POPULATED)
FetchContent_Populate(libcxx)
endif()

endif()

nuttx_create_symlink(${CMAKE_CURRENT_LIST_DIR}/libcxx/include
${CMAKE_BINARY_DIR}/include/libcxx)

configure_file(${CMAKE_CURRENT_LIST_DIR}/../__config_site
${CMAKE_BINARY_DIR}/include/libcxx/__config_site COPYONLY)

set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_CXX_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/include/libcxx)

add_compile_definitions(_LIBCPP_BUILDING_LIBRARY)
if(CONFIG_LIBSUPCXX_TOOLCHAIN)
add_compile_definitions(__GLIBCXX__)
endif()

if(CONFIG_LIBSUPCXX)
add_compile_definitions(__GLIBCXX__)
endif()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)

set(SRCS)
set(SRCSTMP)

file(GLOB SRCS ${CMAKE_CURRENT_LIST_DIR}/libcxx/src/*.cpp)
file(GLOB SRCSTMP ${CMAKE_CURRENT_LIST_DIR}/libcxx/src/experimental/*.cpp)
list(APPEND SRCS ${SRCSTMP})
file(GLOB SRCSTMP ${CMAKE_CURRENT_LIST_DIR}/libcxx/src/filesystem/*.cpp)
list(APPEND SRCS ${SRCSTMP})
file(GLOB SRCSTMP ${CMAKE_CURRENT_LIST_DIR}/libcxx/src/ryu/*.cpp)
list(APPEND SRCS ${SRCSTMP})

if(NOT CONFIG_CXX_LOCALIZATION)
file(
GLOB
SRCSTMP
${CMAKE_CURRENT_LIST_DIR}/libcxx/src/ios.cpp
${CMAKE_CURRENT_LIST_DIR}/libcxx/src/ios.instantiations.cpp
${CMAKE_CURRENT_LIST_DIR}/libcxx/src/iostream.cpp
${CMAKE_CURRENT_LIST_DIR}/libcxx/src/locale.cpp
${CMAKE_CURRENT_LIST_DIR}/libcxx/src/regex.cpp
${CMAKE_CURRENT_LIST_DIR}/libcxx/src/strstream.cpp)
list(REMOVE_ITEM SRCS ${SRCSTMP})
endif()

set(FLAGS -Wno-attributes -Wno-deprecated-declarations -Wno-shadow
-Wno-sign-compare -Wno-cpp)

if(GCCVER GREATER_EQUAL 12)
list(APPEND FLAGS -Wno-maybe-uninitialized -Wno-alloc-size-larger-than)
endif()

nuttx_add_system_library(libcxx)
target_sources(libcxx PRIVATE ${SRCS})
target_compile_options(libcxx PRIVATE ${FLAGS})
target_include_directories(libcxx BEFORE
PRIVATE ${CMAKE_CURRENT_LIST_DIR}/libcxx/src)
endif()
Loading

0 comments on commit db31e56

Please sign in to comment.