pro-cpp-cli-core 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +88 -32
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* PRO C++ CLI Core (With C++20 Modules Topological Sorter)
|
|
5
|
-
* FIX:
|
|
5
|
+
* FIX: Restored initProject!
|
|
6
|
+
* FIX: Smart post-build artifact routing to .build/ directory!
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
const { execSync, spawn } = require('child_process');
|
|
@@ -13,6 +14,8 @@ const [,, command, ...args] = process.argv;
|
|
|
13
14
|
let currentAppProcess = null;
|
|
14
15
|
let watchTimeout = null;
|
|
15
16
|
|
|
17
|
+
const BUILD_DIR = path.join(process.cwd(), '.build');
|
|
18
|
+
|
|
16
19
|
function runSyncCommand(cmd) {
|
|
17
20
|
try {
|
|
18
21
|
execSync(cmd, { stdio: 'inherit' });
|
|
@@ -23,11 +26,19 @@ function runSyncCommand(cmd) {
|
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
function cleanupOldBuilds() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
// 1. Clean .build folder
|
|
30
|
+
if (fs.existsSync(BUILD_DIR)) {
|
|
31
|
+
const files = fs.readdirSync(BUILD_DIR);
|
|
32
|
+
files.forEach(file => {
|
|
33
|
+
if (file.endsWith('.obj') || file.endsWith('.pdb') || file.endsWith('.ilk') || file.endsWith('.ifc') || file.startsWith('app_build_')) {
|
|
34
|
+
try { fs.unlinkSync(path.join(BUILD_DIR, file)); } catch (err) {}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
// 2. Clean root folder (just in case)
|
|
39
|
+
const rootFiles = fs.readdirSync(process.cwd());
|
|
40
|
+
rootFiles.forEach(file => {
|
|
41
|
+
if (file.endsWith('.obj') || file.endsWith('.pdb') || file.endsWith('.ilk') || file.endsWith('.ifc') || (file.startsWith('app_build_') && file.endsWith('.exe'))) {
|
|
31
42
|
try { fs.unlinkSync(path.join(process.cwd(), file)); } catch (err) {}
|
|
32
43
|
}
|
|
33
44
|
});
|
|
@@ -41,7 +52,8 @@ function getSortedCppFiles() {
|
|
|
41
52
|
for (const file of files) {
|
|
42
53
|
const filePath = path.join(dir, file);
|
|
43
54
|
if (fs.statSync(filePath).isDirectory()) {
|
|
44
|
-
|
|
55
|
+
// ИГНОРИРУЕМ ПАПКУ .build, ЧТОБЫ ВОЧЕР НЕ СОШЕЛ С УМА
|
|
56
|
+
if (file !== 'node_modules' && file !== '.vscode' && file !== '.build') {
|
|
45
57
|
scanDir(filePath);
|
|
46
58
|
}
|
|
47
59
|
} else if (filePath.endsWith('.cpp') || filePath.endsWith('.ixx')) {
|
|
@@ -56,11 +68,7 @@ function getSortedCppFiles() {
|
|
|
56
68
|
const exportsMatch = content.match(/export\s+module\s+([a-zA-Z0-9_]+)\s*;/);
|
|
57
69
|
const importsMatches = [...content.matchAll(/import\s+([a-zA-Z0-9_]+)\s*;/g)].map(m => m[1]);
|
|
58
70
|
|
|
59
|
-
return {
|
|
60
|
-
file,
|
|
61
|
-
exports: exportsMatch ? exportsMatch[1] : null,
|
|
62
|
-
imports: importsMatches
|
|
63
|
-
};
|
|
71
|
+
return { file, exports: exportsMatch ? exportsMatch[1] : null, imports: importsMatches };
|
|
64
72
|
});
|
|
65
73
|
|
|
66
74
|
const sortedFiles = [];
|
|
@@ -91,25 +99,57 @@ function initProject() {
|
|
|
91
99
|
const vscodeDir = path.join(process.cwd(), '.vscode');
|
|
92
100
|
if (!fs.existsSync(vscodeDir)) fs.mkdirSync(vscodeDir);
|
|
93
101
|
|
|
94
|
-
|
|
95
|
-
const mainCppContent = `import std.core;\n// C++20 Modules ready!\nint main() { return 0; }`;
|
|
96
|
-
if (!fs.existsSync(mainCppPath)) fs.writeFileSync(mainCppPath, mainCppContent);
|
|
97
|
-
|
|
102
|
+
// 1. tasks.json
|
|
98
103
|
const tasksContent = {
|
|
99
104
|
"version": "2.0.0",
|
|
100
|
-
"tasks": [
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
]
|
|
105
|
+
"tasks": [{
|
|
106
|
+
"type": "cppbuild",
|
|
107
|
+
"label": "DEBUG-BUILD-MSVC",
|
|
108
|
+
"command": "cl.exe",
|
|
109
|
+
"args": ["/std:c++20", "/Zi", "/EHsc", "/nologo", "/Fe${fileDirname}\\.build\\debug_build.exe", "${file}"],
|
|
110
|
+
"problemMatcher": ["$msCompile"],
|
|
111
|
+
"group": "build"
|
|
112
|
+
}]
|
|
110
113
|
};
|
|
111
114
|
fs.writeFileSync(path.join(vscodeDir, 'tasks.json'), JSON.stringify(tasksContent, null, 4));
|
|
112
|
-
|
|
115
|
+
|
|
116
|
+
// 2. c_cpp_properties.json (FIX FOR IDE SQUIGGLES!)
|
|
117
|
+
const propertiesContent = {
|
|
118
|
+
"configurations": [{
|
|
119
|
+
"name": "Win32",
|
|
120
|
+
"includePath": ["${workspaceFolder}/**"],
|
|
121
|
+
"compilerPath": "cl.exe",
|
|
122
|
+
"cStandard": "c17",
|
|
123
|
+
"cppStandard": "c++20",
|
|
124
|
+
"intelliSenseMode": "windows-msvc-x64",
|
|
125
|
+
"compilerArgs": [
|
|
126
|
+
"/std:c++20",
|
|
127
|
+
"/experimental:module",
|
|
128
|
+
"/ifcSearchDir", // Указываем IDE, где искать .ifc файлы!
|
|
129
|
+
"${workspaceFolder}/.build"
|
|
130
|
+
]
|
|
131
|
+
}],
|
|
132
|
+
"version": 4
|
|
133
|
+
};
|
|
134
|
+
fs.writeFileSync(path.join(vscodeDir, 'c_cpp_properties.json'), JSON.stringify(propertiesContent, null, 4));
|
|
135
|
+
|
|
136
|
+
// 3. settings.json (Hide .build folder from UI)
|
|
137
|
+
const settingsContent = {
|
|
138
|
+
"files.exclude": {
|
|
139
|
+
".build": true,
|
|
140
|
+
"**/.build": true
|
|
141
|
+
},
|
|
142
|
+
"C_Cpp.errorSquiggles": "disabled"
|
|
143
|
+
};
|
|
144
|
+
fs.writeFileSync(path.join(vscodeDir, 'settings.json'), JSON.stringify(settingsContent, null, 4));
|
|
145
|
+
|
|
146
|
+
// 4. main.cpp template
|
|
147
|
+
const mainCppPath = path.join(process.cwd(), 'main.cpp');
|
|
148
|
+
if (!fs.existsSync(mainCppPath)) {
|
|
149
|
+
fs.writeFileSync(mainCppPath, `import std.core;\n// C++20 Modules ready!\nint main() { return 0; }`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
console.log("✅ Ready! .vscode configs created. IntelliSense is pointed to .build/");
|
|
113
153
|
}
|
|
114
154
|
|
|
115
155
|
function buildAndRun() {
|
|
@@ -121,15 +161,30 @@ function buildAndRun() {
|
|
|
121
161
|
|
|
122
162
|
if (currentAppProcess) currentAppProcess.kill();
|
|
123
163
|
cleanupOldBuilds();
|
|
164
|
+
if (!fs.existsSync(BUILD_DIR)) fs.mkdirSync(BUILD_DIR);
|
|
124
165
|
|
|
125
|
-
const
|
|
166
|
+
const outputExeName = `app_build_${Date.now()}.exe`;
|
|
167
|
+
|
|
126
168
|
console.log(`\n🔨 Compiling with SMART DEPENDENCY GRAPH...`);
|
|
127
169
|
|
|
128
|
-
|
|
170
|
+
// Компилируем чисто, без странных флагов
|
|
171
|
+
const compileCmd = `cl.exe /std:c++20 /nologo /EHsc ${cppFiles} /Fe"${outputExeName}"`;
|
|
129
172
|
|
|
130
173
|
if (runSyncCommand(compileCmd)) {
|
|
131
|
-
|
|
132
|
-
|
|
174
|
+
// МАГИЯ ПЕРЕНОСА: Двигаем все созданные файлы в папку .build
|
|
175
|
+
const files = fs.readdirSync(process.cwd());
|
|
176
|
+
files.forEach(file => {
|
|
177
|
+
if (file.endsWith('.obj') || file.endsWith('.ifc') || file.endsWith('.pdb') || file.endsWith('.ilk') || file === outputExeName) {
|
|
178
|
+
try {
|
|
179
|
+
fs.renameSync(path.join(process.cwd(), file), path.join(BUILD_DIR, file));
|
|
180
|
+
} catch(e) {}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
console.log(`🟢 RUNNING -> .build\\${outputExeName}\n` + "-".repeat(40));
|
|
185
|
+
|
|
186
|
+
// Запускаем из папки .build
|
|
187
|
+
currentAppProcess = spawn(`.\\.build\\${outputExeName}`, [], { shell: true, stdio: 'inherit' });
|
|
133
188
|
currentAppProcess.on('close', (code) => {
|
|
134
189
|
if (code !== null) console.log("-".repeat(40) + `\n🛑 Process exited with code ${code}`);
|
|
135
190
|
});
|
|
@@ -143,7 +198,8 @@ function watchProject() {
|
|
|
143
198
|
buildAndRun();
|
|
144
199
|
|
|
145
200
|
fs.watch(process.cwd(), { recursive: true }, (eventType, filename) => {
|
|
146
|
-
|
|
201
|
+
// Игнорируем всё, что происходит внутри папки .build
|
|
202
|
+
if (filename && (filename.endsWith('.cpp') || filename.endsWith('.ixx') || filename.endsWith('.h')) && !filename.includes('.build')) {
|
|
147
203
|
clearTimeout(watchTimeout);
|
|
148
204
|
watchTimeout = setTimeout(() => {
|
|
149
205
|
console.clear();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pro-cpp-cli-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/anton-po-github/pro-cpp-cli-core.git"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"description": "The ultimate C++ Developer Experience for Windows",
|
|
13
13
|
"main": "index.js",
|
|
14
14
|
"bin": {
|
|
15
|
-
"procpp": "
|
|
15
|
+
"procpp": "index.js"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"start": "node index.js"
|
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
],
|
|
27
27
|
"author": "PRO Developer",
|
|
28
28
|
"license": "MIT"
|
|
29
|
-
}
|
|
29
|
+
}
|