Files
GDevelop/GDevelop.js/scripts/sync-versions.js
Florian Rival 762f7ca19c Avoid unnecessary recompilation of many C++ files at each build
Only show in developer changelog
2024-09-09 13:39:34 +02:00

36 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const path = require('path');
const fs = require('fs');
// 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}"
`;
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.');
}