Commit a9ad68f7bf47ad1e67f1d32d1acf85961c62dc9f

Authored by Peter M. Groen
0 parents

Setting up the repository

CMakeLists.txt 0 → 100644
  1 +++ a/CMakeLists.txt
  1 +cmake_minimum_required(VERSION 3.0)
  2 +LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/submodules/cmake)
  3 +
  4 +include(projectheader)
  5 +project_header(datatypes)
  6 +
  7 +# set(REPOSITORY_PACKAGE_NAME ${PROJECT_NAME} CACHE STRING "Repository name for ${PROJECT_NAME}" FORCE)
  8 +add_subdirectory(src)
  9 +
  10 +# Test applications for each component.
  11 +# add_subdirectory(tests)
  12 +
  13 +
... ...
scripts/create_pri_files.sh 0 → 100755
  1 +++ a/scripts/create_pri_files.sh
  1 +#!/bin/bash
  2 +
  3 +REPO_DIR=${PWD}
  4 +DIRECTORIES=`ls -1d *`
  5 +
  6 +function create_source_file() {
  7 + SOURCE_FILE="$1.pri"
  8 +
  9 + echo "Building file : ${SOURCE_FILE}"
  10 + if [ -e ${SOURCE_FILE} ]; then
  11 + rm -vf ${SOURCE_FILE}
  12 + fi
  13 +
  14 + HEADERFILES=`ls -1 *.h`
  15 + SOURCEFILES=`ls -1 *.cpp`
  16 + HEADERLINE="HEADERS += ${HEADERFILES}"
  17 + SOURCELINE="SOURCES += ${SOURCEFILES}"
  18 +
  19 + echo "=================================="
  20 + echo "== ${SOURCE_FILE} =="
  21 + echo "=================================="
  22 + echo "== A D D I N G H E A D E R S =="
  23 + echo "=================================="
  24 + echo ${HEADERLINE} | sed 's/=\ /=\ \$\$PWD\//g' | sed 's/.h\ /.h\ \\\n\t\t\$\$PWD\//g' > ./${SOURCE_FILE}
  25 + echo " " >> ./${SOURCE_FILE}
  26 + echo "=================================="
  27 + echo "== A D D I N G S O U R C E S =="
  28 + echo "=================================="
  29 + echo ${SOURCELINE} | sed 's/=\ /=\ \$\$PWD\//g' | sed 's/.cpp\ /.cpp\ \\\n\t\t\$\$PWD\//g' >> ./${SOURCE_FILE}
  30 + echo " "
  31 + echo " "
  32 + echo " "
  33 + echo " "
  34 +}
  35 +
  36 +for directory in ${DIRECTORIES}
  37 +do
  38 + if [ -d ${REPO_DIR}/${directory} ]; then
  39 + cd ${REPO_DIR}/${directory}
  40 + create_source_file ${directory}
  41 + cd ${REPO_DIR}
  42 + else
  43 + echo "${REPO_DIR}/${directory} is not a directory"
  44 + fi
  45 +done
... ...
scripts/setup_submodules 0 → 100755
  1 +++ a/scripts/setup_submodules
  1 +#!/bin/bash
  2 +
  3 +# ===============================================
  4 +# == Setting some environment variables
  5 +# ===============================================
  6 +GIT_URL_OPEN="http://gitlab.osdev.nl/open_source"
  7 +GIT_URL_CLOSED="git@gitlab.osdev.nl:closed_source"
  8 +
  9 +FUNC_RESULT="-1"
  10 +
  11 +# Name : print_usage_exit()
  12 +# Description : Print the way this script is intended to be used and exit.
  13 +# Parameters : None.
  14 +# Returns : err_code 1 to the Operating System
  15 +# --------------------------------------------------------------------------------------
  16 +function print_usage_exit()
  17 +{
  18 + echo "Usage $0 -i|--install|-u|--update"
  19 + echo " -i or --install Install the submodules mentioned in the submodules.list"
  20 + echo " -u or --update Update the submodules mentioned in the submodules.list"
  21 + echo " "
  22 + exit 1
  23 +}
  24 +
  25 +# Name : check_top_or_sub
  26 +# Description : Determine if we're running in a "single" lib-build or part of a
  27 +# "meta"-repository ( submodule ).
  28 +# Parameters : None
  29 +# Returns : Updates the value FUNC_RESULT.
  30 +# -1 - We're neither a git-repo or submodule.
  31 +# 0 - We're a submodule
  32 +# 1 - We're a top-repo ( Single library )
  33 +# --------------------------------------------------------------------------------------
  34 +function check_top_or_sub()
  35 +{
  36 + # This function checks if we're the top-repository.
  37 + # In that case we need the submodules.. If we're already a submodule,
  38 + # we simply exit this script with a message
  39 + if [ -e ./.git ]; then
  40 + FUNC_RESULT="1"
  41 + return
  42 + elif [ -e ../.git ]; then
  43 + if [ -e ../.submodules ]; then
  44 + echo "Seems like we're already a submodule. Nothing to do here."
  45 + FUNC_RESULT="0"
  46 + return
  47 + fi
  48 + fi
  49 + FUNC_RESULT="-1"
  50 + return
  51 +}
  52 +
  53 +# Name : check_working_dir
  54 +# Description : If we're in the top of our repo, we can run this script further.
  55 +# Parameters : None.
  56 +# Returns : Updates the value FUNC_RESULT.
  57 +# -1 - Not used.
  58 +# 0 - We're not on the top-level
  59 +# 1 - We're at the top-level. Good to go.
  60 +# --------------------------------------------------------------------------------------
  61 +function check_working_dir()
  62 +{
  63 + FUNC_RESULT="-1"
  64 + # Check if we're in the top-level directory of our repository.
  65 + if [ -f ./scripts/submodules.list ]; then
  66 + # We're good to go
  67 + FUNC_RESULT="1"
  68 + return
  69 + fi
  70 + FUNC_RESULT="0"
  71 + return
  72 +}
  73 +
  74 +# Name : read_submodules
  75 +# Description : Read the list of submodules needed for this project
  76 +# Parameters : None
  77 +# Returns : Updates the value FUNC_RESULT
  78 +# 0 - Module list was not found
  79 +# 1 - Module list was found and read.
  80 +# --------------------------------------------------------------------------------------
  81 +function read_submodules()
  82 +{
  83 + FUNC_RESULT="-1"
  84 + if [ -e ./scripts/submodules.list ]; then
  85 + source ./scripts/submodules.list
  86 + FUNC_RESULT="1"
  87 + return
  88 + fi
  89 +
  90 + echo "Submodules list not found...."
  91 + FUNC_RESULT="0"
  92 + return
  93 +}
  94 +
  95 +# Name : add_submodules
  96 +# Description : Configure the repo to add the submodules.
  97 +# Parameters : None.
  98 +# Returns : None.
  99 +# --------------------------------------------------------------------------------------
  100 +function add_submodules()
  101 +{
  102 + echo -e "Adding SubModule(s)."
  103 + for SUB_MODULE in ${SUB_MODULES_OPEN}
  104 + do
  105 + git submodule add -f ${GIT_URL_OPEN}/${SUB_MODULE}.git submodules/${SUB_MODULE}
  106 + git config submodule.${SUB_MODULE}.url ${GIT_URL_OPEN}/${SUB_MODULE}.git
  107 + done
  108 +
  109 + for SUB_MODULE in ${SUB_MODULES_CLOSED}
  110 + do
  111 + echo {GIT_URL_CLOSED}/${SUB_MODULE}.git
  112 + git submodule add -f ${GIT_URL_CLOSED}/${SUB_MODULE}.git submodules/${SUB_MODULE}
  113 + git config submodule.${SUB_MODULE}.url ${GIT_URL_CLOSED}/${SUB_MODULE}.git
  114 + done
  115 +
  116 +}
  117 +
  118 +# Name : get_submodules
  119 +# Description : Actually get the submodules from gitlab and add them.
  120 +# Parameters : None
  121 +# Returns : None
  122 +# --------------------------------------------------------------------------------------
  123 +function get_submodules()
  124 +{
  125 + git submodule update --init --recursive
  126 +}
  127 +
  128 +# Name : update_submodules
  129 +# Description : Update the submodules already added.
  130 +# Parameters : None
  131 +# Returns : None
  132 +# --------------------------------------------------------------------------------------
  133 +function update_submodules()
  134 +{
  135 + git submodule update --recursive
  136 +}
  137 +
  138 +# =============================================================================
  139 +# == T H E M A I N E N T R Y O F T H I S S C R I P T ==
  140 +# =============================================================================
  141 +check_top_or_sub
  142 +if [ "${FUNC_RESULT}" == "0" ]; then
  143 + echo "Seems like we're a submodule already or not part of a repository."
  144 + exit 0
  145 +fi
  146 +
  147 +check_working_dir
  148 +if [ "${FUNC_RESULT}" == "0" ]; then
  149 + echo "Go to the top of this repository and type : scripts/setup_submodules [-i|--install]"
  150 + exit 0
  151 +fi
  152 +
  153 +read_submodules
  154 +
  155 +case "$1" in
  156 + -i*|--install*)
  157 + echo "Installing submodules for this repository ( ${PWD} )"
  158 + add_submodules
  159 + get_submodules
  160 + ;;
  161 + -u*|--update*)
  162 + echo "Update submodules : ${SUB_MODULES}"
  163 + update_submodules
  164 + ;;
  165 + *)
  166 + echo "No parameters found..."
  167 + print_usage_exit
  168 + ;;
  169 +esac
  170 +
... ...
scripts/submodules.list 0 → 100644
  1 +++ a/scripts/submodules.list
  1 +SUB_MODULES_OPEN="cmake"
  2 +
  3 +SUB_MODULES_CLOSED=""
... ...
submodules.list 0 → 100644
  1 +++ a/submodules.list
  1 +SUB_MODULES="osdev_versioning
  2 +cmake"
... ...