mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Avoid unnecessary recompilation of many C++ files at each build
Only show in developer changelog
This commit is contained in:
@@ -1,11 +1,35 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const [gdVersion, prerelease] = require('../../newIDE/electron-app/app/package.json').version.split('-');
|
||||
const versionPrivContent =
|
||||
`// This file is automatically synchronizing with newIDE/electron-app/app/package.json version
|
||||
// Get the version details from the package.json
|
||||
const [
|
||||
gdVersion,
|
||||
prerelease,
|
||||
] = require('../../newIDE/electron-app/app/package.json').version.split('-');
|
||||
|
||||
const versionPrivContent = `// This file is automatically synchronizing with newIDE/electron-app/app/package.json version
|
||||
// Check GDevelop/scripts/sync-versions.js for more details
|
||||
#define GD_VERSION_STRING "${gdVersion}-${prerelease || 0}"
|
||||
`;
|
||||
|
||||
fs.writeFileSync(path.join(__dirname, "../../Core/GDCore/Tools/VersionPriv.h"), versionPrivContent, "utf8");
|
||||
const filePath = path.join(__dirname, '../../Core/GDCore/Tools/VersionPriv.h');
|
||||
|
||||
let currentContent;
|
||||
try {
|
||||
currentContent = fs.readFileSync(filePath, 'utf8');
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
// VersionPriv.h does not exist, will be created.
|
||||
} else {
|
||||
console.log('❌ Error reading VersionPriv.h file');
|
||||
throw error; // Rethrow error if not a 'file not found' error
|
||||
}
|
||||
}
|
||||
|
||||
// Write to the file only if the content has changed to avoid unnecessary recompilation of C++ files.
|
||||
if (currentContent !== versionPrivContent) {
|
||||
fs.writeFileSync(filePath, versionPrivContent, 'utf8');
|
||||
console.log('✅ VersionPriv.h updated with the version number.');
|
||||
} else {
|
||||
console.log('ℹ️ VersionPriv.h is up to date.');
|
||||
}
|
||||
|
Reference in New Issue
Block a user