Skip to content
Snippets Groups Projects
Commit e82a0294 authored by mark's avatar mark
Browse files

ENH: add help/usage for dirToString, wmkdep. Add dirToString -strip option.

- The dirToString -strip option is simple, but reduces effort for the caller.
parent 46ecad8f
Branches
Tags
No related merge requests found
......@@ -34,7 +34,7 @@
if [ -r Make/files ]
then
echo "Error: Make/files already exists - exiting"
echo "Error: Make/files already exists - exiting" 1>&2
exit 1
fi
......@@ -43,38 +43,32 @@ dirToString=$WM_DIR/platforms/$WM_ARCH$WM_COMPILER/dirToString
[ -d Make ] || mkdir Make
rm -f Make/files
for dir in `find . -type d -print`
for dir in $(find . -mindepth 1 -type d -print)
do
case "$dir" in
. | ./Make | ./lnInclude )
# Skip special directories
;;
*)
baseDir=`echo $dir | sed 's%^\./%%'`
baseDirName=`echo $baseDir | $dirToString`
echo $baseDirName " = " $baseDir >> Make/files
echo "$(echo $dir | $dirToString -strip) = ${dir#./}"
;;
esac
done
echo >> Make/files
done >> Make/files
[ -s Make/files ] && echo >> Make/files
for file in `find . -name "*.[cCylLfF]" -type f -print`
for file in $(find . -type f -name "*.[cCylLfF]" -print)
do
fileName=${file##*/}
pathName=`echo ${file%/*} | sed -e 's%^\.%%' -e 's%^/%%' | $dirToString`
pathName=$(echo ${file%/*} | $dirToString -strip)
if [ -n "$pathName" ]
then
echo '$('$pathName')/'$fileName >> Make/files
echo '$('$pathName')/'"${file##*/}"
else
echo $fileName >> Make/files
echo "${file##*/}"
fi
done
done >> Make/files
echo >> Make/files
echo 'EXE = $(FOAM_APPBIN)/'${PWD##*/} >> Make/files
echo 'EXE = $(FOAM_APPBIN)/'"${PWD##*/}" >> Make/files
#------------------------------------------------------------------------------
......@@ -34,7 +34,7 @@
if [ -r Make/options ]
then
echo "Error: Make/options already exists - exiting"
echo "Error: Make/options already exists - exiting" 1>&2
exit 1
fi
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -33,22 +33,61 @@ Usage
e.g.
using sh
baseDirName=`echo $dir | sed 's%^\./%%' | $bin/dirToString`
baseDirName=$(echo $dir | $bin/dirToString -strip)
using csh
set baseDirName=`echo $dir | sed 's%^\./%%' | $bin/dirToString`
set baseDirName=`echo $dir | $bin/dirToString -strip`
\*----------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main()
int main(int argc, char* argv[])
{
int c;
int nextupper = 0;
if (argc > 1)
{
if (!strncmp(argv[1], "-h", 2)) /* -h, -help */
{
fprintf
(
stderr,
"\nUsage: %s [-strip]\n\n",
"dirToString"
);
fprintf
(
stderr,
" -strip ignore leading [./] characters.\n\n"
"Transform dir1/dir2 to camel-case dir1Dir2\n\n"
);
return 0;
}
if (!strcmp(argv[1], "-s") || !strcmp(argv[1], "-strip")) /* -s, -strip */
{
while ((c=getchar()) != EOF && (c == '.' || c == '/'))
{
/* nop */
}
if (c == EOF)
{
return 0;
}
putchar(c);
}
}
while ((c=getchar()) != EOF)
{
if (c == '/')
......@@ -60,13 +99,12 @@ int main()
if (nextupper)
{
putchar(toupper(c));
nextupper = 0;
}
else
{
putchar(c);
}
nextupper = 0;
}
}
......
......@@ -4,7 +4,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -147,10 +147,29 @@ int main(int argc, char* argv[])
char *basePos, *dotPos;
int i, silent;
if (argc == 1)
if (argc < 2)
{
fprintf(stderr, "input file not supplied\n");
exit(1);
return 1;
}
else if (!strncmp(argv[1], "-h", 2)) /* -h, -help */
{
fprintf
(
stderr,
"\nUsage: %s [-Idir ... -Idir] [-iheader .. -iheader] filename\n\n",
"wmkdep"
);
fprintf
(
stderr,
" -Idir Directories to be searched for headers.\n"
" -iheader Headers to be ignored.\n\n"
"Dependency list generator, similar to 'cpp -M'\n\n"
);
return 0;
}
sourceFile = strdup(argv[argc-1]);
......@@ -161,7 +180,7 @@ int main(int argc, char* argv[])
}
else
{
basePos++;
++basePos;
}
if
......@@ -176,18 +195,18 @@ int main(int argc, char* argv[])
"cannot find extension in source file name %s\n",
sourceFile
);
exit(1);
return 1;
}
/* count number of -I directories */
nDirectories = 0;
for (i = 1; i < argc; i++)
for (i = 1; i < argc; ++i)
{
if (strncmp(argv[i], "-I", 2) == 0)
{
if (strlen(argv[i]) > 2)
{
nDirectories++;
++nDirectories;
}
}
}
......@@ -196,7 +215,7 @@ int main(int argc, char* argv[])
/* build list of -I directories and add -i ignores */
nDirectories = 0;
for (i = 1; i < argc; i++)
for (i = 1; i < argc; ++i)
{
if (strncmp(argv[i], "-I", 2) == 0)
{
......@@ -240,7 +259,7 @@ int main(int argc, char* argv[])
puts("\n");
for (i = 0; i < nDirectories; i++)
for (i = 0; i < nDirectories; ++i)
{
free(directories[i]);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment