mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: reduce wmake bootstrap dependencies
- remove make target for wmdep (flex-based scanner), which eliminates a bootstrap dependency on flex. As of OpenFOAM-v1806, wmdep has been superseded by wmdepend (ragel-based scanner). - replace dirToString binary with shell/awk equivalent for simpler maintenance. The utility is very rarely used (auto scanning to create Make/files) so there is no performance difference.
This commit is contained in:
committed by
Andrew Heather
parent
2e544489bf
commit
137130e437
90
wmake/scripts/dirToString
Executable file
90
wmake/scripts/dirToString
Executable file
@ -0,0 +1,90 @@
|
||||
#!/bin/sh
|
||||
#------------------------------------------------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
# \\/ M anipulation |
|
||||
#-------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Script
|
||||
# dirToString
|
||||
#
|
||||
# Usage
|
||||
# dirToString path/to/file
|
||||
#
|
||||
# Description
|
||||
# Converts a directory path into a camelCase string.
|
||||
# Leading [./] characters are stripped by default.
|
||||
#
|
||||
# For example,
|
||||
# input: dir1/dir2/dir3
|
||||
# output: dir1Dir2Dir3
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
usage() {
|
||||
exec 1>&2
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
cat<<USAGE
|
||||
|
||||
Usage: ${0##*/} [OPTION] dir
|
||||
|
||||
options:
|
||||
-no-strip Do not ignore leading [./] characters
|
||||
-strip Ignore leading [./] characters (default)
|
||||
-h, -help Print the usage
|
||||
|
||||
Converts a directory path into a camelCase string
|
||||
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Parse arguments and options
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
optStrip=true
|
||||
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
# Print help
|
||||
(-h | -help*)
|
||||
usage
|
||||
;;
|
||||
(-s | -strip)
|
||||
optStrip=true
|
||||
;;
|
||||
(-no-strip)
|
||||
unset optStrip
|
||||
;;
|
||||
(--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
(*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "$optStrip" ]
|
||||
then
|
||||
dirName="$1"
|
||||
else
|
||||
# Ignore any leading ./ characters
|
||||
dirName="$(echo ""$1"" | sed -e 's@^[./]*@@')"
|
||||
fi
|
||||
|
||||
dirName=$(echo "$dirName" | \
|
||||
awk 'BEGIN{FS="";RS="/";ORS=""} {if (FNR>1) {$0=toupper(substr($0,1,1))substr($0,2)}} 1')
|
||||
|
||||
echo "$dirName"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -33,7 +33,8 @@
|
||||
# Usage : makeFiles
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
dirToString="${WM_DIR:-$WM_PROJECT_DIR/wmake}/platforms/$WM_ARCH$WM_COMPILER/dirToString"
|
||||
scriptDir="${0%/*}" # The script dir
|
||||
dirToString="$scriptDir/dirToString"
|
||||
|
||||
if [ -r Make/files ]
|
||||
then
|
||||
@ -60,7 +61,7 @@ do
|
||||
# Skip special directories
|
||||
;;
|
||||
*)
|
||||
echo "$(echo $dir | $dirToString -strip) = ${dir#./}"
|
||||
echo "$($dirToString "$dir") = ${dir#./}"
|
||||
;;
|
||||
esac
|
||||
done > Make/files
|
||||
@ -68,7 +69,7 @@ done > Make/files
|
||||
|
||||
for file in $(find . -name "*.[cCylLfF]" -type f -print)
|
||||
do
|
||||
pathName=$(echo ${file%/*} | $dirToString -strip)
|
||||
pathName="$($dirToString "${file%/*}")"
|
||||
|
||||
if [ -n "$pathName" ]
|
||||
then
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd |
|
||||
# \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
@ -62,8 +62,6 @@ include $(GENERAL_RULES)/general
|
||||
.PHONY: all clean
|
||||
|
||||
all: \
|
||||
$(WMAKE_BIN)/dirToString$(EXT_EXE) \
|
||||
$(WMAKE_BIN)/wmkdep$(EXT_EXE) \
|
||||
$(WMAKE_BIN)/wmkdepend$(EXT_EXE)
|
||||
@echo "built wmake-bin for $(WM_ARCH)$(WM_COMPILER)"
|
||||
|
||||
@ -72,11 +70,6 @@ clean:
|
||||
@rm -rf $(WMAKE_BIN) 2>/dev/null
|
||||
@rmdir $(shell dirname $(WMAKE_BIN)) 2>/dev/null || true
|
||||
|
||||
$(WMAKE_BIN)/dirToString$(EXT_EXE): dirToString.c
|
||||
@mkdir -p $(WMAKE_BIN)
|
||||
$(call QUIET_MESSAGE,compile,$(<F))
|
||||
$E $(cc) $(cFLAGS) $(<F) -o $@
|
||||
|
||||
$(WMAKE_BIN)/wmkdep$(EXT_EXE): wmkdep.l
|
||||
@mkdir -p $(WMAKE_BIN)
|
||||
$(call QUIET_MESSAGE,flex,$(<F))
|
||||
|
||||
@ -1,115 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011 OpenFOAM Foundation
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
dirToString
|
||||
|
||||
Description
|
||||
Converts a directory path into a camelCase string.
|
||||
e.g. dir1/dir2/dir3 becomes dir1Dir2Dir3
|
||||
|
||||
Usage
|
||||
echo dirName | dirToString
|
||||
|
||||
e.g.
|
||||
using sh
|
||||
baseDirName=$(echo $dir | $bin/dirToString -strip)
|
||||
|
||||
using csh
|
||||
set baseDirName=`echo $dir | $bin/dirToString -strip`
|
||||
|
||||
\*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/* The executable name (for messages), without requiring access to argv[] */
|
||||
#define EXENAME "dirToString"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int c;
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (!strncmp(argv[1], "-h", 2))
|
||||
{
|
||||
/* Option: -h, -help */
|
||||
|
||||
fputs
|
||||
(
|
||||
"\nUsage: " EXENAME
|
||||
" [-strip]\n\n"
|
||||
" -strip ignore leading [./] characters.\n\n"
|
||||
"Converts a directory path into a camelCase string\n\n",
|
||||
stderr
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "-s") || !strcmp(argv[1], "-strip"))
|
||||
{
|
||||
/* Option: -s, -strip */
|
||||
|
||||
while ((c=getchar()) != EOF && (c == '.' || c == '/'))
|
||||
{
|
||||
/* nop */
|
||||
}
|
||||
|
||||
if (c == EOF)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
putchar(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int nextUpper = 0;
|
||||
while ((c = getchar()) != EOF)
|
||||
{
|
||||
if (c == '/')
|
||||
{
|
||||
nextUpper = 1;
|
||||
}
|
||||
else if (nextUpper)
|
||||
{
|
||||
putchar(toupper(c));
|
||||
nextUpper = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
putchar(c);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
Reference in New Issue
Block a user