From bbca8c1a035abb8788e27c802a50609c41807c39 Mon Sep 17 00:00:00 2001 From: Peter M. Groen Date: Tue, 25 Jan 2022 11:47:11 +0100 Subject: [PATCH] Added comments to the script. --- .gitignore | 1 + CMakeLists.txt | 6 +++--- scripts/setup_submodules | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 73aa673..8226778 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ build/* CMakeLists.txt.user* cmake/ versioning/ +/.gitmodules diff --git a/CMakeLists.txt b/CMakeLists.txt index 38cff83..285de61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 3.0) +project(osdev_mqtt) # ============================================================================== # Check to see if we're a submodule or top-repo. if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake) @@ -32,6 +33,5 @@ add_subdirectory(src) add_subdirectory(examples/pub) add_subdirectory(examples/sub) - -# include(packaging) -# package_component() +include(packaging) +package_component() diff --git a/scripts/setup_submodules b/scripts/setup_submodules index cd5f202..b8c7a6e 100755 --- a/scripts/setup_submodules +++ b/scripts/setup_submodules @@ -1,10 +1,16 @@ #!/bin/bash -# ================= -# = Do not change. -# ================= + +# =============================================== +# == Setting some environment variables +# =============================================== GIT_URL_SUBS="http://gitlab.osdev.nl/open_source" -FUNC_RESULT="" +FUNC_RESULT="-1" +# Name : print_usage_exit() +# Description : Print the way this script is intended to be used and exit. +# Parameters : None. +# Returns : err_code 1 to the Operating System +# -------------------------------------------------------------------------------------- function print_usage_exit() { echo "Usage $0 -i|--install|-u|--update" @@ -14,6 +20,15 @@ function print_usage_exit() exit 1 } +# Name : check_top_or_sub +# Description : Determine if we're running in a "single" lib-build or part of a +# "meta"-repository ( submodule ). +# Parameters : None +# Returns : Updates the value FUNC_RESULT. +# -1 - We're neither a git-repo or submodule. +# 0 - We're a submodule +# 1 - We're a top-repo ( Single library ) +# -------------------------------------------------------------------------------------- function check_top_or_sub() { # This function checks if we're the top-repository. @@ -29,12 +44,21 @@ function check_top_or_sub() return fi fi - FUNC_RESULT="0" + FUNC_RESULT="-1" return } +# Name : check_working_dir +# Description : If we're in the top of our repo, we can run this script further. +# Parameters : None. +# Returns : Updates the value FUNC_RESULT. +# -1 - Not used. +# 0 - We're not on the top-level +# 1 - We're at the top-level. Good to go. +# -------------------------------------------------------------------------------------- function check_working_dir() { + FUNC_RESULT="-1" # Check if we're in the top-level directory of our repository. if [ -f ./scripts/submodules.list ]; then # We're good to go @@ -45,27 +69,58 @@ function check_working_dir() return } +# Name : read_submodules +# Description : Read the list of submodules needed for this project +# Parameters : None +# Returns : Updates the value FUNC_RESULT +# 0 - Module list was not found +# 1 - Module list was found and read. +# -------------------------------------------------------------------------------------- function read_submodules() { + FUNC_RESULT="-1" if [ -e ./scripts/submodules.list ]; then source ./scripts/submodules.list + FUNC_RESULT="1" + return fi + + echo "Submodules list not found...." + FUNC_RESULT="0" + return } +# Name : add_submodules +# Description : Configure the repo to add the submodules. +# Parameters : None. +# Returns : None. +# -------------------------------------------------------------------------------------- function add_submodules() { + echo -e "Adding SubModule(s)." for SUB_MODULE in ${SUB_MODULES} do + echo -e "< ${SUB_MODULE} >" git submodule add -f ${GIT_URL_SUBS}/${SUB_MODULE}.git ${SUB_MODULE} git config submodule.${SUB_MODULE}.url ${GIT_URL_SUBS}/${SUB_MODULE}.git done } +# Name : get_submodules +# Description : Actually get the submodules from gitlab and add them. +# Parameters : None +# Returns : None +# -------------------------------------------------------------------------------------- function get_submodules() { git submodule update --init --recursive } +# Name : update_submodules +# Description : Update the submodules already added. +# Parameters : None +# Returns : None +# -------------------------------------------------------------------------------------- function update_submodules() { git submodule update --recursive -- libgit2 0.21.4