已合并
!2644 clang edits #55
pavelmironchik创建于 2025年10月27日
!2644 clang edits #55
已合并
pavelmironchik创建于 2025年10月27日
6 个文件变更+48-41
Dclang-format/apply-correct-format.sh+0-16
@@ -1,16 +0,0 @@
1-#!/bin/bash
2- 
3-# $1 - filePath to patch (default - `./patches/clang-format.patch`)
4- 
5-patchFile=${1:-$curDir"/patches/clang-format.patch"}
6-patchFile=$(readlink -m $patchFile)
7- 
8-curDir="$(pwd)"
9-rootDir="$(git rev-parse --show-toplevel)"
10- 
11-cd $rootDir
12- 
13-echo "Try to apply patch: "$patchFile
14-git apply --stat --apply --unsafe-paths --verbose $patchFile
15- 
16-cd $curDir
Dclang-format/package.json+0-17
@@ -1,17 +0,0 @@
1-{
2- "private": true,
3- "version": "2.1.7",
4- "description": "format code with clang-format tool",
5- "license": "Apache-2.0",
6- "keywords": [],
7- "config": {
8- "sig_path": "../external/arkoala-arkts/framework/native/src ../external/arkoala-arkts/arkui/src/ani/native/",
9- "patch_path": "./patches/sig_patch.patch"
10- },
11- "scripts": {
12- "check-format": "bash ./check-format.sh ${PATCH_FILE} ${DIR_PATH}",
13- "apply-format": "bash ./apply-correct-format.sh ${PATCH_FILE}",
14- "check-format:external": "DIR_PATH=$npm_package_config_sig_path PATCH_FILE=$npm_package_config_patch_path npm run check-format",
15- "apply-format:external": "PATCH_FILE=$npm_package_config_patch_path npm run apply-format"
16- }
17-}
Atools/clang-format/.gitignore+1-0
@@ -0,0 +1 @@
1+patches
Atools/clang-format/apply-correct-format.sh+22-0
@@ -0,0 +1,22 @@
1+#!/bin/bash
kolegovilya
kolegovilyakolegovilya2025年10月27日

Bash script is not really "cross-platform" solution. Maybe one day we could think about rewrite this script to something more windows-friendly.

likedislike
2+ 
3+# $1 - search path (file or directory or multiple)
4+ 
5+curDir="$(pwd)"
6+rootDir="$(git rev-parse --show-toplevel)"
7+ 
8+searchDir=($@)
9+searchDir=${searchDir[@]:0}
10+searchDir=$(readlink -m $searchDir)
11+ 
12+cd $rootDir
13+searchDir=$(realpath -m --relative-to=$rootDir $searchDir)
14+echo "Search paths: "$searchDir
15+files=($(find $searchDir -not -iname "*.ttf.cc" -and -type f -and \( -iname '*.h' -or -iname '*.cc' \)))
16+ 
17+for file in ${files[*]}
18+do
19+ echo "Applying clang format: "$file
20+ clang-format $file --style=file -i
21+done
22+cd $curDir
Rclang-format/check-format.shtools/clang-format/check-format.sh+7-8
@@ -1,25 +1,25 @@
1#!/bin/bash1#!/bin/bash
2 2 
3-# $1 - filePath to save patch3+# $1 - search path (file or directory or multiple)
4-# $2 - search path (file or directory or multiple)
5 4 
6curDir="$(pwd)"5curDir="$(pwd)"
7rootDir="$(git rev-parse --show-toplevel)"6rootDir="$(git rev-parse --show-toplevel)"
8 7 
9-patchFile=${1:-$curDir"/patches/clang-format.patch"}8+mkfile() { mkdir -p "$(dirname "$1")" && touch "$1" ; }
9+ 
10+patchFile="./patches/clang-format.patch"
10patchFile=$(readlink -m $patchFile)11patchFile=$(readlink -m $patchFile)
12+mkfile $patchFile
11> $patchFile13> $patchFile
12 14 
13searchDir=($@)15searchDir=($@)
14-searchDir=${searchDir[@]:1}16+searchDir=${searchDir[@]:0}
15searchDir=$(readlink -m $searchDir)17searchDir=$(readlink -m $searchDir)
16 18 
17cd $rootDir19cd $rootDir
18searchDir=$(realpath -m --relative-to=$rootDir $searchDir)20searchDir=$(realpath -m --relative-to=$rootDir $searchDir)
19echo "Search paths: "$searchDir21echo "Search paths: "$searchDir
20-files=($(find $searchDir -type f -iname '*.h' -o -iname '*.cpp'))22+files=($(find $searchDir -not -iname "*.ttf.cc" -and -type f -and \( -iname '*.h' -or -iname '*.cpp' \)))
21- 
22-# find idlize-copy/external/arkoala-arkts/ \( \( -iname '*.h' -or -iname '*.cpp' \) -and -not -path "*/node_modules/*" -and -not -path "*/tools/*" \)
23 23 
24for file in ${files[*]}24for file in ${files[*]}
25do 25do
@@ -34,4 +34,3 @@ done
34cd $curDir34cd $curDir
35 35 
36echo "Patch saved: "$patchFile36echo "Patch saved: "$patchFile
37- 
Atools/clang-format/package.json+18-0
@@ -0,0 +1,18 @@
1+{
2+ "private": true,
3+ "version": "2.1.7",
4+ "description": "format code with clang-format tool",
5+ "license": "Apache-2.0",
6+ "keywords": [],
7+ "config": {
8+ "sig_path": "../../external/interop/src/cpp/ ../../external/incremental/graphics/native/platform/cpp ../../external/subset/arkoala-arkts/framework/native/src/generated ../../external/libarkts/native/src",
pavelmironchikkolegovilya
pavelmironchikpavelmironchik2025年10月27日

need to think carefully about relative paths, migration to repo sync is planned to be initialized soon and we must not forget about all of this

likedislike
kolegovilyakolegovilya2025年10月27日

sig_path name could be misleading. Now we have a lot of names to one thing: external/sig/koala_project etc. I thing we should align in naming and use one name convension in our projects.

likedislike
peterz_5686
peterz_5686
2025年10月27日 评论:
9+ "patch_path": "./tools/clang-format/patches/clang-format.patch"
10+ },
11+ "scripts": {
12+ "check-format": "bash ./check-format.sh ${DIR_PATH}",
13+ "apply-format": "bash ./apply-correct-format.sh ${DIR_PATH}",
14+ "check-format:external": "DIR_PATH=$npm_package_config_sig_path npm run check-format",
15+ "apply-format:external": "DIR_PATH=$npm_package_config_sig_path npm run apply-format",
16+ "apply-patch": "cd ../../ && git apply --stat --apply --unsafe-paths --verbose $npm_package_config_patch_path"
17+ }
18+}