@@ -6,6 +6,91 @@ get_mem_available_kb() {
6
6
grep MemAvailable /proc/meminfo | awk ' {print $2}'
7
7
}
8
8
9
+ copy_ignored_errors () {
10
+ local build_target_base=" $1 "
11
+ local target=" $2 "
12
+
13
+ local present_working_dir=" $( pwd) "
14
+ local config_file=" $present_working_dir /configuration/$target .json"
15
+ local build_dir=" $( pwd) /$build_target_base /out/vs/editor/common/errors"
16
+ local output_file=" $build_dir /ignored-errors.json"
17
+
18
+ echo " Processing ignored errors for target: $target "
19
+ mkdir -p " $build_dir "
20
+
21
+ # Step 1: Collect all .json files from common-ignored-errors directory
22
+ local common_files=()
23
+ if [[ -d " ${present_working_dir} /common-ignored-errors" ]]; then
24
+ echo " Step 1: Looking for common ignored errors files"
25
+ while IFS= read -r -d ' ' file; do
26
+ common_files+=(" $file " )
27
+ echo " Found: $( basename " $file " ) "
28
+ done < <( find " ${present_working_dir} /common-ignored-errors" -name " *.json" -print0 2> /dev/null || true)
29
+ fi
30
+
31
+ # Step 2: Collect target-specific .json files if path is not null
32
+ local target_files=()
33
+ if [ -f " $config_file " ]; then
34
+ local ignored_errors_path=$( jq -r ' .ignoredErrors.path' " $config_file " )
35
+ if [[ " $ignored_errors_path " != " null" && -n " $ignored_errors_path " && -d " ${present_working_dir} /$ignored_errors_path " ]]; then
36
+ echo " Step 2: Looking for target-specific ignored errors files in: $ignored_errors_path "
37
+ while IFS= read -r -d ' ' file; do
38
+ target_files+=(" $file " )
39
+ echo " Found: $( basename " $file " ) "
40
+ done < <( find " ${present_working_dir} /$ignored_errors_path " -name " *.json" -print0 2> /dev/null || true)
41
+ else
42
+ echo " Step 2: Skipping target-specific files (path is null or doesn't exist)"
43
+ fi
44
+ else
45
+ echo " Config file not found: $config_file "
46
+ fi
47
+
48
+ # Step 3: Merge all JSON files
49
+ echo " Step 3: Merging all ignored errors files"
50
+ local temp_file=$( mktemp)
51
+ echo ' {"stringPatterns": [], "regexPatterns": []}' > " $temp_file "
52
+
53
+ # Function to clean JSON (remove comments)
54
+ clean_and_merge () {
55
+ local file=" $1 "
56
+ local temp_clean=$( mktemp)
57
+ # Remove single-line comments and multi-line comments
58
+ sed ' s|//.*$||g' " $file " | sed ' /\/\*/,/\*\//d' > " $temp_clean "
59
+ jq -s ' .[0] as $base | .[1] as $new | $base + {stringPatterns: ($base.stringPatterns + ($new.stringPatterns // [])), regexPatterns: ($base.regexPatterns + ($new.regexPatterns // []))}' " $temp_file " " $temp_clean " > " ${temp_file} .tmp" && mv " ${temp_file} .tmp" " $temp_file "
60
+ rm " $temp_clean "
61
+ }
62
+
63
+ # Merge common files
64
+ if [[ ${# common_files[@]} -gt 0 ]]; then
65
+ for file in " ${common_files[@]} " ; do
66
+ if [[ -f " $file " ]]; then
67
+ echo " Merging: $( basename " $file " ) "
68
+ clean_and_merge " $file "
69
+ fi
70
+ done
71
+ fi
72
+
73
+ # Merge target-specific files
74
+ if [[ ${# target_files[@]} -gt 0 ]]; then
75
+ for file in " ${target_files[@]} " ; do
76
+ if [[ -f " $file " ]]; then
77
+ echo " Merging: $( basename " $file " ) "
78
+ clean_and_merge " $file "
79
+ fi
80
+ done
81
+ fi
82
+
83
+ # Copy merged result to output location
84
+ cp " $temp_file " " $output_file "
85
+ rm " $temp_file "
86
+
87
+ # Report final counts
88
+ local string_count=$( jq ' .stringPatterns | length' " $output_file " )
89
+ local regex_count=$( jq ' .regexPatterns | length' " $output_file " )
90
+ echo " Created ignored-errors.json with $string_count string patterns and $regex_count regex patterns"
91
+ echo " Output written to: $output_file "
92
+ }
93
+
9
94
build () {
10
95
local code_oss_build_target_base=" $1 "
11
96
@@ -29,6 +114,7 @@ build() {
29
114
env \
30
115
NODE_OPTIONS=" --max-old-space-size=${max_space_size_mb} " \
31
116
npm run gulp " $build_target "
117
+ cd ..
32
118
}
33
119
34
120
main () {
@@ -37,6 +123,7 @@ main() {
37
123
local build_target_base=$( " $( dirname " $0 " ) /determine-build-target.sh" " $target " )
38
124
echo " Building for target: $build_target_base "
39
125
build " $build_target_base "
126
+ copy_ignored_errors " $build_target_base " " $target "
40
127
}
41
128
42
- main " $@ "
129
+ main " $@ "
0 commit comments