config-tools: introduce xslt transform and clang-format in genconf.sh
Add "transform" to generate following files with xsltproc in genconf.sh: - ivshmem_cfg.h - misc_cfg.h - pt_intx.c - vm_configurations.c - vm_configurations.h Add code formatter using clang-format. It formats the gernerated code with customized condfiguration if clang-format package and configuraion file ".clang-format" exist. Add sed in genconf.sh "transform" to replace the copyright "YEAR" of generated files. Tracked-On: #5980 Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com> Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
parent
6d81112428
commit
5f2f82f4d8
|
@ -0,0 +1,89 @@
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
# BasedOnStyle: LLVM
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: DontAlign
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlinesLeft: false
|
||||||
|
AlignOperands: false
|
||||||
|
AlignTrailingComments: false
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: MultiLine
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: false
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: true
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
IndentBraces: false
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
ColumnLimit: 120
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
ConstructorInitializerIndentWidth: 8
|
||||||
|
ContinuationIndentWidth: 8
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||||
|
Priority: 2
|
||||||
|
- Regex: '^(<|"(gtest|isl|json)/)'
|
||||||
|
Priority: 3
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 1
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentWidth: 8
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: Inner
|
||||||
|
ObjCBlockIndentWidth: 4
|
||||||
|
ObjCSpaceAfterProperty: true
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
PointerAlignment: Right
|
||||||
|
ReflowComments: true
|
||||||
|
SortIncludes: false
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Cpp11
|
||||||
|
TabWidth: 8
|
||||||
|
UseTab: ForContinuationAndIndentation
|
||||||
|
...
|
|
@ -6,6 +6,9 @@ base_dir=$1
|
||||||
board_xml=$2
|
board_xml=$2
|
||||||
scenario_xml=$3
|
scenario_xml=$3
|
||||||
out=$4
|
out=$4
|
||||||
|
unified_xml=$5
|
||||||
|
scenario=$(xmllint --xpath "string(//@scenario)" --xinclude $unified_xml)
|
||||||
|
year=$(date +'%Y')
|
||||||
|
|
||||||
apply_patch () {
|
apply_patch () {
|
||||||
echo "Applying patch ${1}:"
|
echo "Applying patch ${1}:"
|
||||||
|
@ -26,6 +29,37 @@ if [ $? -ne 0 ]; then
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! which xsltproc ; then
|
||||||
|
echo "xsltproc cannot be found, please install it and make sure it is in your PATH."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
transform() {
|
||||||
|
echo "Generating ${1}:"
|
||||||
|
xsltproc -o ${out}/scenarios/${scenario}/${1} --xinclude --xincludestyle ${tool_dir}/xforms/${1}.xsl ${unified_xml}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to generate ${1} with xsltproc!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sed -i -e "s/YEAR/$year/" ${out}/scenarios/${scenario}/${1}
|
||||||
|
echo "${1} was generated using xsltproc succesfully."
|
||||||
|
}
|
||||||
|
|
||||||
|
transform vm_configurations.c
|
||||||
|
transform vm_configurations.h
|
||||||
|
transform pt_intx.c
|
||||||
|
transform ivshmem_cfg.h
|
||||||
|
transform misc_cfg.h
|
||||||
|
|
||||||
|
if which clang-format ; then
|
||||||
|
find ${out}/scenarios/${scenario} -iname *.h -o -iname *.c \
|
||||||
|
| xargs clang-format --style=file -i --fallback-style=none
|
||||||
|
else
|
||||||
|
echo "clang-format cannot be found. The generated files under ${out}/scenarios/${scenario} are not formatted."
|
||||||
|
echo "clang-format is a tool to format the C code automatically and improve the code readibility."
|
||||||
|
echo "Please install clang-format and format the generated files if those need to be included and reviewed."
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f ${diffconfig_list} ]; then
|
if [ -f ${diffconfig_list} ]; then
|
||||||
cd ${out} &&
|
cd ${out} &&
|
||||||
cat ${diffconfig_list} | while read line; do
|
cat ${diffconfig_list} | while read line; do
|
||||||
|
|
|
@ -238,7 +238,7 @@ $(HV_CONFIG_H): $(HV_UNIFIED_XML)
|
||||||
@echo "$@ generated"
|
@echo "$@ generated"
|
||||||
|
|
||||||
$(HV_CONFIG_TIMESTAMP): $(HV_UNIFIED_XML) ${HV_DIFFCONFIG_LIST} | $(HV_CONFIG_DIR)
|
$(HV_CONFIG_TIMESTAMP): $(HV_UNIFIED_XML) ${HV_DIFFCONFIG_LIST} | $(HV_CONFIG_DIR)
|
||||||
@sh $(BASEDIR)/scripts/genconf.sh $(BASEDIR) $(HV_BOARD_XML) $(HV_SCENARIO_XML) $(HV_CONFIG_DIR)
|
@sh $(BASEDIR)/scripts/genconf.sh $(BASEDIR) $(HV_BOARD_XML) $(HV_SCENARIO_XML) $(HV_CONFIG_DIR) $(HV_UNIFIED_XML)
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
.PHONY: defconfig
|
.PHONY: defconfig
|
||||||
|
@ -253,7 +253,7 @@ showconfig:
|
||||||
|
|
||||||
diffconfig:
|
diffconfig:
|
||||||
@rm -rf $(HV_CONFIG_A_DIR) $(HV_CONFIG_B_DIR)
|
@rm -rf $(HV_CONFIG_A_DIR) $(HV_CONFIG_B_DIR)
|
||||||
@sh $(BASEDIR)/scripts/genconf.sh $(BASEDIR) $(BOARD_FILE) $(HV_SCENARIO_XML) $(HV_CONFIG_A_DIR)
|
@sh $(BASEDIR)/scripts/genconf.sh $(BASEDIR) $(BOARD_FILE) $(HV_SCENARIO_XML) $(HV_CONFIG_A_DIR) $(HV_UNIFIED_XML)
|
||||||
@cd $(HV_CONFIG_DIR) && find . -name '*.c' -or -name '*.h' -or -name '*.config' -or -name '*.asl' | while read f; do \
|
@cd $(HV_CONFIG_DIR) && find . -name '*.c' -or -name '*.h' -or -name '*.config' -or -name '*.asl' | while read f; do \
|
||||||
nf=$(HV_CONFIG_B_DIR)/$${f}; mkdir -p `dirname $${nf}` && cp $${f} $${nf}; \
|
nf=$(HV_CONFIG_B_DIR)/$${f}; mkdir -p `dirname $${nf}` && cp $${f} $${nf}; \
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue