Skip to content

Commit

Permalink
cleanup for yodajs
Browse files Browse the repository at this point in the history
  • Loading branch information
yorkie committed Dec 3, 2019
1 parent cf28ddc commit 9b7aa79
Show file tree
Hide file tree
Showing 18 changed files with 320 additions and 319 deletions.
195 changes: 195 additions & 0 deletions framework/cmake-modules/common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
include(CMakeParseArguments)

# multiValueArgs:
# HINTS
# INC_PATH_SUFFIX
# LIB_PATH_SUFFIX
# HEADERS
# STATIC_LIBS
# SHARED_LIBS
# VERSION_SHARED_LIBS
# VERSIONS
# options:
# REQUIRED
# RPATH
# RPATH_LINK
function (findPackage name)

unset(rfp_HINTS CACHE)
unset(rfp_INC_PATH_SUFFIX CACHE)
unset(rfp_LIB_PATH_SUFFIX CACHE)
unset(rfp_HEADERS CACHE)
unset(rfp_STATIC_LIBS CACHE)
unset(rfp_SHARED_LIBS CACHE)
unset(rfp_REQUIRED CACHE)
unset(rfp_RPATH CACHE)
unset(rfp_RPATH_LINK CACHE)
unset(rfp_VERSION_SHARED_LIBS CACHE)
unset(rfp_VERSIONS CACHE)

# parse arguments, rfp(rokid find package)
set(options
REQUIRED
RPATH
RPATH_LINK
)
set(multiValueArgs
HINTS
HEADERS
STATIC_LIBS
SHARED_LIBS
INC_PATH_SUFFIX
LIB_PATH_SUFFIX
VERSION_SHARED_LIBS
VERSIONS
)
cmake_parse_arguments(rfp "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

if (rfp_REQUIRED)
set (logprio FATAL_ERROR)
else()
set (logprio STATUS)
endif()
unset(find_path_extra_option CACHE)
if (rfp_HINTS)
set(find_path_extra_option NO_DEFAULT_PATH)
endif()
list(APPEND rfp_HINTS /usr)
list(APPEND rfp_INC_PATH_SUFFIX include)
list(APPEND rfp_LIB_PATH_SUFFIX lib)

foreach (hfile IN LISTS rfp_HEADERS)
unset(inc_root CACHE)
find_path(inc_root
NAMES ${hfile}
HINTS ${rfp_HINTS}
PATH_SUFFIXES ${rfp_INC_PATH_SUFFIX}
${find_path_extra_option}
)
if (inc_root)
list(APPEND includes ${inc_root})
message(STATUS "found ${hfile} in path ${inc_root}")
else()
message(${logprio} "not find ${hfile}, suffix = ${rfp_INC_PATH_SUFFIX}")
endif()
endforeach()
if (includes)
list (REMOVE_DUPLICATES includes)
endif()

foreach (lib IN LISTS rfp_STATIC_LIBS)
unset(libPathName CACHE)
find_library(
libPathName
NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}
HINTS ${rfp_HINTS}
PATH_SUFFIXES ${rfp_LIB_PATH_SUFFIX}
)

if (libPathName)
list(APPEND archives ${libPathName})
else()
message(${logprio} "${name}: Not Found lib${lib}.a. HINTS ${rfp_HINTS} LIB_PATH_SUFFIX ${rfp_LIB_PATH_SUFFIX}")
endif()
endforeach()

foreach (lib IN LISTS rfp_SHARED_LIBS)
unset(libPathName CACHE)
if (rfp_VERSION)
if (${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dylib")
set(lib ${CMAKE_SHARED_LIBRARY_PREFIX}${lib}.${rfp_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX})
else()
set(lib ${CMAKE_SHARED_LIBRARY_PREFIX}${lib}${CMAKE_SHARED_LIBRARY_SUFFIX}.${rfp_VERSION})
endif()
message(STATUS "finding library ${lib}")
endif(rfp_VERSION)
find_library(
libPathName
NAMES ${lib}
HINTS ${rfp_HINTS}
PATH_SUFFIXES ${rfp_LIB_PATH_SUFFIX}
)
if (libPathName)
get_filename_component(libPath ${libPathName} DIRECTORY)
list(APPEND lib_link_paths ${libPath})
list(APPEND lib_names ${lib})
else()
message(${logprio} "${name}: Not Found ${lib}. HINTS ${rfp_HINTS} LIB_PATH_SUFFIX ${rfp_LIB_PATH_SUFFIX}")
endif()
endforeach()

unset(verLibsLen CACHE)
list(LENGTH rfp_VERSION_SHARED_LIBS verLibsLen)
if (verLibsLen GREATER 0)
foreach (idx RANGE verLibsLen)
unset(libPathName CACHE)
list(GET rfp_VERSION_SHARED_LIBS ${idx} lib)
list(GET rfp_VERSIONS ${idx} vernum)
if (${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dylib")
set(lib ${CMAKE_SHARED_LIBRARY_PREFIX}${lib}.${vernum}${CMAKE_SHARED_LIBRARY_SUFFIX})
else()
set(lib ${CMAKE_SHARED_LIBRARY_PREFIX}${lib}${CMAKE_SHARED_LIBRARY_SUFFIX}.${vernum})
endif()
find_library(
libPathName
NAMES ${lib}
HINTS ${rfp_HINTS}
PATH_SUFFIXES ${rfp_LIB_PATH_SUFFIX}
)
if (libPathName)
get_filename_component(libPath ${libPathName} DIRECTORY)
list(APPEND lib_link_paths ${libPath})
list(APPEND ver_lib_names ${lib})
else()
message(${logprio} "${name}: Not Found ${lib}. HINTS ${rfp_HINTS} LIB_PATH_SUFFIX ${rfp_LIB_PATH_SUFFIX}")
endif()
endforeach()
endif()

if (lib_link_paths)
list(REMOVE_DUPLICATES lib_link_paths)
endif()
if (lib_names)
list(REMOVE_DUPLICATES lib_names)
endif()

set(${name}_INCLUDE_DIRS ${includes} PARENT_SCOPE)
list(APPEND ldflags ${archives})
foreach (path IN LISTS lib_link_paths)
list(APPEND ldflags -L${path})
if (rfp_RPATH)
list(APPEND ldflags -Wl,-rpath,${path})
endif()
if (rfp_RPATH_LINK)
list(APPEND ldflags -Wl,-rpath-link,${path})
endif()
endforeach()
foreach (lib IN LISTS lib_names)
list(APPEND ldflags ${lib})
endforeach()
foreach (lib IN LISTS ver_lib_names)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
list(APPEND ldflags -l:${lib})
else()
list(APPEND ldflags ${lib})
endif()
endforeach()
set(${name}_LIBRARIES ${ldflags} PARENT_SCOPE)

endfunction(findPackage)

function (git_commit_id outvar)
unset(cid CACHE)
if (${ARGC} GREATER 1)
set(gitdir ${ARGV1})
else()
set(gitdir ${CMAKE_CURRENT_SOURCE_DIR})
endif()
execute_process(
COMMAND git show --format=%H -s
OUTPUT_VARIABLE cid
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${gitdir}
)
set(${outvar} ${cid} PARENT_SCOPE)
endfunction(git_commit_id)
21 changes: 21 additions & 0 deletions framework/cmake-modules/toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# this is required
SET(CMAKE_SYSTEM_NAME Linux)

# specify the cross compiler
SET(CMAKE_C_COMPILER ${TOOLCHAIN_HOME}/bin/${CROSS_PREFIX}gcc)
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_HOME}/bin/${CROSS_PREFIX}g++)

# where is the target environment
# SET(CMAKE_FIND_ROOT_PATH ${CROSS_ROOT_PATH})

# search for programs in the build host directories (not necessary)
# SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
# SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
# SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

SET(CROSS_COMPILE_CXXFLAGS "-D__STDC_LIMIT_MACROS")

# configure Boost and Qt
# SET(QT_QMAKE_EXECUTABLE /opt/qt-embedded/qmake)
# SET(BOOST_ROOT /opt/boost_arm)
2 changes: 1 addition & 1 deletion openwrt/package/nodejs/node-caps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ define Package/node-caps
SECTION:=libs
CATEGORY:=node_modules
TITLE:=node-caps
DEPENDS:=+libstdcpp +shadow-node +mutils
DEPENDS:=+libstdcpp +shadow-node +mingutils
endef

define Build/InstallDev
Expand Down
2 changes: 1 addition & 1 deletion openwrt/package/nodejs/node-flock/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=node-flock
PKG_VERSION:=v1.0.1
PKG_VERSION:=master
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
Expand Down
23 changes: 8 additions & 15 deletions openwrt/package/yodaos/flora/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,34 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=flora
PKG_VERSION:=
PKG_VERSION:=master
PKG_RELEASE:=1

PKG_SOURCE_DIR:=$(ROKID_DIR)/frameworks/allspark/flora

PKG_FIXUP:=libtool
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
PKG_LICENSE:=GPL-2.0+
PKG_SOURCE_PROTO:=git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/yodaos-project/flora.git
PKG_SOURCE_VERSION:=$(PKG_VERSION)

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk

define Package/flora
SECTION:=libs
CATEGORY:=rokid
CATEGORY:=yodaos
TITLE:=flora
DEPENDS:=+mutils +libncursesw
DEPENDS:=+libstdcpp +mingutils +libncursesw
endef

define Package/flora/description
property
endef

CMAKE_OPTIONS += \
-DCUSTOM_CMAKE_MODULES=${PKG_SOURCE_DIR}/../cmake-modules \
-DCUSTOM_CMAKE_MODULES=$(ROKID_DIR)/framework/cmake-modules \
-DCLI_LOGLEVEL=warning \
-DDEBUG_FOR_YODAV8=ON
CMAKE_FIND_ROOT_PATH := ${CMAKE_FIND_ROOT_PATH};${STAGING_DIR}

define Build/Prepare
$(CP) $(PKG_SOURCE_DIR)/* $(PKG_BUILD_DIR)
$(call Build/Prepare/Default,)
endef

define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include
$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
Expand Down
6 changes: 3 additions & 3 deletions openwrt/package/yodaos/mingutils/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ include $(INCLUDE_DIR)/cmake.mk

define Package/mingutils
SECTION:=libs
CATEGORY:=rokid
TITLE:=mutils
CATEGORY:=yodaos
TITLE:=mingutils
DEPENDS:=+libstdcpp +libpthread
endef

Expand All @@ -40,7 +40,7 @@ define Build/InstallDev
$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.a $(1)/usr/lib/
endef

define Package/mutils/install
define Package/mingutils/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so $(1)/usr/lib/
endef
Expand Down
49 changes: 0 additions & 49 deletions openwrt/package/yodaos/mutils/Makefile

This file was deleted.

2 changes: 0 additions & 2 deletions openwrt/package/yodaos/yoda.js/Config.in

This file was deleted.

Loading

0 comments on commit 9b7aa79

Please sign in to comment.