# !kmk_ash # $Id: gen-slickedit-workspace.sh 65831 2017-02-21 13:38:32Z vboxsync $ ## @file # Script for generating a SlickEdit workspace. # # # Copyright (C) 2009-2015 Oracle Corporation # # This file is part of VirtualBox Open Source Edition (OSE), as # available from http://www.virtualbox.org. This file is free software; # you can redistribute it and/or modify it under the terms of the GNU # General Public License (GPL) as published by the Free Software # Foundation, in version 2 as it comes in the "COPYING" file of the # VirtualBox OSE distribution. VirtualBox OSE is distributed in the # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. # # # Some constants. # MY_CAT="kmk_cat" MY_CP="kmk_cp" MY_MKDIR="kmk_mkdir" MY_MV="kmk_mv" MY_SED="kmk_sed" MY_RM="kmk_rm" MY_SLEEP="kmk_sleep" MY_EXPR="kmk_expr" MY_SVN="svn" #MY_SORT="kmk_cat" MY_SORT="sort" # # Globals. # MY_PROJECT_FILES="" MY_OUT_DIRS="\ out/${KBUILD_TARGET}.${KBUILD_TARGET_ARCH}/${KBUILD_TYPE} \ out/${BUILD_TARGET}.${BUILD_TARGET_ARCH}/${BUILD_TYPE} \ out/${KBUILD_TARGET}.${KBUILD_TARGET_ARCH}/debug \ out/${BUILD_TARGET}.${BUILD_TARGET_ARCH}/debug \ out/${KBUILD_TARGET}.${KBUILD_TARGET_ARCH}/release \ out/${BUILD_TARGET}.${BUILD_TARGET_ARCH}/release \ out/linux.amd64/debug \ out/linux.x86/debug \ out/win.amd64/debug \ out/win.x86/debug \ out/darwin.amd64/debug \ out/darwin.x86/debug \ out/haiku.amd64/debug \ out/haiku.x86/debug \ out/solaris.amd64/debug \ out/solaris.x86/debug"; # # Parameters w/ defaults. # MY_ROOT_DIR=".." MY_OUT_DIR="SlickEdit" MY_PRJ_PRF="VBox-" MY_WS_NAME="VirtualBox.vpw" MY_DBG="" MY_WINDOWS_HOST="" MY_OPT_MINIMAL="" MY_OPT_USE_WILDCARDS="yes" #MY_KBUILD_PATH="${KBUILD_PATH}" #test -z "${MY_KBUILD_PATH}" && MY_KBUILD_PATH="${PATH_KBUILD}" #MY_KBUILD="" ## # Gets the absolute path to an existing directory. # # @param $1 The path. my_abs_dir() { if test -n "${PWD}"; then MY_ABS_DIR=`cd ${MY_ROOT_DIR}/${1} && echo ${PWD}` else # old cygwin shell has no PWD and need adjusting. MY_ABS_DIR=`cd ${MY_ROOT_DIR}/${1} && pwd | ${MY_SED} -e 's,^/cygdrive/\(.\)/,\1:/,'` fi if test -z "${MY_ABS_DIR}"; then MY_ABS_DIR="${1}" fi } ## # Gets the file name part of a path. # # @param $1 The path. my_get_name() { SAVED_IFS=$IFS IFS=":/ " set $1 while test $# -gt 1 -a -n "${2}"; do shift; done IFS=$SAVED_IFS #echo "$1" export MY_GET_NAME=$1 } ## # Generate file entry for the specified file if it was found to be of interest. # # @param $1 The output file name base. # @param $2 The file name. # @param $3 Optional folder override. my_file() { # sort and filter by file type. case "$2" in # drop these. *.kup|*~|*.pyc|*.exe|*.sys|*.dll|*.o|*.obj|*.lib|*.a|*.ko) return 0 ;; # by prefix or directory component. tst*|*/testcase/*) MY_FOLDER="$1-Testcases.lst" ;; # by extension. *.c|*.cpp|*.m|*.mm|*.pl|*.py|*.as|*.c.h|*.cpp.h|*.java) MY_FOLDER="$1-Sources.lst" ;; *.h|*.hpp|*.mm) MY_FOLDER="$1-Headers.lst" ;; *.asm|*.s|*.S|*.inc|*.mac) MY_FOLDER="$1-Assembly.lst" ;; *) MY_FOLDER="$1-Others.lst" ;; esac if test -n "$3"; then MY_FOLDER="$1-$3.lst" fi ## @todo only files which are in subversion. # if ${MY_SVN} info "${2}" > /dev/null 2>&1; then my_get_name "${2}" echo ' ' >> "${MY_FOLDER}" # fi } ## # Generate file entry for the specified file if it was found to be of interest. # # @param $1 The output file name base. # @param $2 The wildcard spec. # @param $3 Optional folder override. my_wildcard() { if test -n "$3"; then MY_FOLDER="$1-$3.lst" else MY_FOLDER="$1-All.lst" fi EXCLUDES="*.log;*.kup;*~;*.pyc;*.exe;*.sys;*.dll;*.o;*.obj;*.lib;*.a;*.ko;*.class;*.cvsignore;*.done;*.project;*.actionScriptProperties;*.scm-settings;*.svnpatch.rej;*.svn-base;.svn/*;*.gitignore" echo ' ' >> "${MY_FOLDER}" } ## # Generate file entries for the specified sub-directory tree. # # @param $1 The output filename. # @param $2 The sub-directory. # @param $3 Optional folder override. my_sub_tree() { if test -n "$MY_DBG"; then echo "dbg: my_sub_tree: ${2}"; fi # Skip .svn directories. case "$2" in */.svn|*/.svn) return 0 ;; esac # Process the files in the directory. for f in $2/*; do if test -d "${f}"; then my_sub_tree "${1}" "${f}" "${3}" else my_file "${1}" "${f}" "${3}" fi done return 0; } ## # Generate folders for the specified directories and files. # # @param $1 The output (base) file name. # @param $2+ The files and directories to traverse. my_generate_folder() { MY_FILE="$1" shift # Zap existing file collections. > "${MY_FILE}-All.lst" > "${MY_FILE}-Sources.lst" > "${MY_FILE}-Headers.lst" > "${MY_FILE}-Assembly.lst" > "${MY_FILE}-Testcases.lst" > "${MY_FILE}-Others.lst" # Traverse the directories and files. while test $# -ge 1 -a -n "${1}"; do for f in ${MY_ROOT_DIR}/$1; do if test -d "${f}"; then if test -z "${MY_OPT_USE_WILDCARDS}"; then my_sub_tree "${MY_FILE}" "${f}" else case "${f}" in ${MY_ROOT_DIR}/include*) #my_sub_tree "${MY_FILE}" "${f}" "Headers" my_wildcard "${MY_FILE}" "${f}" "Headers" ;; *) my_wildcard "${MY_FILE}" "${f}" ;; esac fi else my_file "${MY_FILE}" "${f}" fi done shift done # Generate the folders. if test -s "${MY_FILE}-All.lst"; then ${MY_SORT} "${MY_FILE}-All.lst" | ${MY_SED} -e 's/