diff --git a/.gitignore b/.gitignore index 4951f80..6bb82a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ ./build/ +./build/* diff --git a/CMakeLists.txt b/CMakeLists.txt index ab5e207..2fccb8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,24 +1,31 @@ cmake_minimum_required(VERSION 3.0) # ============================================================================== # Check to see if we're a submodule or top-repo. -message( STATUS "Current Directory : ${CMAKE_CURRENT_SOURCE_DIR}" ) - if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + message( STATUS "Looks like we're a single module" ) LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) + message( STATUS "Looks like we're a submodule" ) LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) else() message( FATAL_ERROR "No cmake directory found. Did you run the submodules script?" ) endif() - +# ============================================================================== # Check to see if there is versioning information available if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/osdev_versioning/cmake) LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/osdev_versioning/cmake) - include(osdevversion) +elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../osdev_versioning/cmake) + LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../osdev_versioning/cmake) +else() + message( FATAL_ERROR "No ${CURRENT_SOURCE_DIR}/osdev_versioning directory found. Did you run the submodules script?" ) endif() +# ============================================================================== +# = Include build information +include(osdevversion) include(projectheader) + project_header(osdev_mqtt) add_subdirectory(src) diff --git a/scripts/setup_submodules b/scripts/setup_submodules index f551a15..52e7155 100755 --- a/scripts/setup_submodules +++ b/scripts/setup_submodules @@ -1,4 +1,9 @@ #!/bin/bash +# ================= +# = Do not chenge. +# ================= +GIT_URL_SUBS="http://gitlab.osdev.nl/open_source" +TOP_REPO="-1" function print_usage_exit() { echo "Usage $0 -i|--install|-u|--update" @@ -8,17 +13,41 @@ function print_usage_exit() { exit 1 } +function check_top_or_sub() { + # This function checks if we're the top-repository. + # In that case we need the submodules.. If we're already a submodule, + # we simply exit this script with a message + if [ -d ./.git ]; then + return 1 + elif [ -d ../.git ]; then + if [ -f ../.submodules ]; then + echo "Seems like we're already a submodule. Nothing to do here." + return 0 + fi + fi + return 0 +} + +function check_working_dir() { + # Check if we're in the top-level directory of our repository. + if [ -f ./scripts/submodules.list ]; then + # We're good to go + return 1 + fi + return 0 +} + function read_submodules() { - if [ -e ./submodules.list ]; then - source ./submodules.list + if [ -e ./scripts/submodules.list ]; then + source ./scripts/submodules.list fi } function add_submodules() { for SUB_MODULE in ${SUB_MODULES} do - git submodule add -f git@gitlab.osdev.nl:OpenSystemsDevelopment/${SUB_MODULE} ${SUB_MODULE} - git config submodule.${SUB_MODULE}.url git@gitlab.osdev.nl:OpenSystemsDevelopment/${SUB_MODULE} + git submodule add -f ${GIT_URL_SUBS}/${SUB_MODULE} ${SUB_MODULE} + git config submodule.${SUB_MODULE}.url ${GIT_URL_SUBS}/${SUB_MODULE} done } @@ -33,6 +62,18 @@ function update_submodules() { # ============================================================================= # == T H E M A I N E N T R Y O F T H I S S C R I P T == # ============================================================================= +RESULT=check_top_or_sub() +if [ $RESULT -eq 0 ]; then + echo "Seems like we're a submodule already or not part of a repository." + exit 0 +fi + +RESULT=check_working_dir() +if [ $RESULT -eq 0 ]; then + echo "Go to the top of this repository and type : scripts/setup_submodules [-i|--install]" + exit 0 +fi + read_submodules case "$1" in