-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathutil.ts
More file actions
72 lines (64 loc) · 1.96 KB
/
Copy pathutil.ts
File metadata and controls
72 lines (64 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { execSync } from "child_process";
import { writeFileSync } from "fs";
import path from "path";
import { exit } from "process";
const $ = (command: string) => {
try {
return execSync(command);
} catch (e) {
exit(1);
}
};
const labels = {
object: "🧩", // Puzzle piece to represent an object
descriptor: "📝", // Memo to represent a descriptor
enum: "🔢", // Input numbers to represent an enumeration
union: "🔗", // Link symbol to represent a union of types
errors: "🚨", // Warning sign to represent errors
};
export const writeFile = (
label: keyof typeof labels,
name: string,
content: string,
) => {
const descriptors = label === "object" ? false : true;
const file = path.resolve(
__dirname,
`../../cpp/rnwgpu/api/${descriptors ? "descriptors" : ""}/${name}.h`,
);
$(`touch ${file}`);
writeFileSync(file, content, "utf8");
console.log(
`${labels[label]} ${file.substring(file.indexOf("/package/") + "/package/".length)}`,
);
};
export const checkDuplicateHeaders = (cppPath: string) => {
// Check for duplicate header names and issue warnings
const duplicateHeaders = $(
`find ${cppPath} -name '*.h' -type f | sed 's/.*\\///' | sort | uniq -d`,
).toString();
if (duplicateHeaders.trim()) {
console.warn("⚠️ WARNING: Found duplicate header names:");
let hasConflicts = false;
duplicateHeaders
.split("\n")
.filter(Boolean)
.forEach((filename: string) => {
const fullPaths = $(
`find ${cppPath} -name "${filename}" -type f`,
).toString();
const paths = fullPaths.split("\n").filter(Boolean);
console.warn(` ${filename}:`);
paths.forEach((filePath: string) => {
console.warn(` ${filePath}`);
});
hasConflicts = true;
});
if (hasConflicts) {
console.error(
"❌ ERROR: Duplicate headers found that will cause iOS build conflicts!",
);
exit(1);
}
}
};