Remove font binaries, download during UI build

Closes #714.
This commit is contained in:
Oliver Hamlet
2016-12-01 19:03:12 +00:00
parent fba0aa5cb8
commit 66dcb29d10
12 changed files with 56 additions and 23 deletions
-8
View File
@@ -516,14 +516,6 @@ add_custom_command(TARGET LOOT POST_BUILD
"${CEF_LOCALES_DIR}/${CEF_LOCALE_FILE}"
$<TARGET_FILE_DIR:LOOT>/resources/l10n/${CEF_LOCALE_FILE})
# Copy UI fonts. Not necessary for the build, but useful for testing.
FOREACH(font Roboto-Bold.ttf Roboto-BoldItalic.ttf Roboto-Italic.ttf Roboto-Light.ttf Roboto-LightItalic.ttf Roboto-Medium.ttf Roboto-MediumItalic.ttf Roboto-Regular.ttf)
add_custom_command(TARGET LOOT POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_SOURCE_DIR}/resources/ui/fonts/${font}"
$<TARGET_FILE_DIR:LOOT>/resources/ui/fonts/${font})
ENDFOREACH()
# Build the UI HTML.
add_custom_command(TARGET LOOT POST_BUILD
COMMAND "node" "${CMAKE_SOURCE_DIR}/scripts/build_ui.js"
+4 -1
View File
@@ -13,9 +13,12 @@
"homepage": "https://github.com/loot/loot",
"private": true,
"dependencies": {
"decompress": "^4.0.0",
"decompress-unzip": "^4.0.1",
"fs-extra": "^0.30.0",
"hydrolysis": "^1.24.1",
"replace": "^0.3.0"
"replace": "^0.3.0",
"request": "^2.79.0"
},
"devDependencies": {
"bower": "^1.7.1",
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+26 -14
View File
@@ -3,6 +3,7 @@ const helpers = require('./helpers');
const hyd = require('hydrolysis');
const fs = require('fs-extra');
const path = require('path');
const getRobotoFiles = require('./get_roboto_files').getRobotoFiles;
function getHtmlImports(filePath) {
return hyd.Analyzer.analyze(filePath).then((analyzer) =>
@@ -85,20 +86,31 @@ function copyFiles(pathsPromise, destinationRootPath) {
});
}
helpers.getAppReleasePaths('.').forEach(releasePath => {
const index = 'src/gui/html/index.html';
const destinationRootPath = `${releasePath.path}/resources/ui`;
const imports = new Set();
const url = 'https://github.com/google/roboto/releases/download/v2.135/roboto-hinted.zip';
const fontsPath = 'build/fonts';
copyFiles(getRecursiveHtmlImports(index, imports), destinationRootPath);
copyFiles(getJavaScriptSources(index), destinationRootPath);
fs.copySync('src/gui/html/css', `${destinationRootPath}/css`);
fs.copySync('resources/ui/css/dark-theme.css', `${destinationRootPath}/css/dark-theme.css`);
fs.copySync('resources/ui/fonts', `${destinationRootPath}/fonts`);
copyNormalisedFile(index, `${destinationRootPath}/index.html`);
Promise.resolve().then(() => {
if (!fs.existsSync(fontsPath)) {
return getRobotoFiles(url, fontsPath);
}
// This is the only JS file referenced by a HTML import (neon-animation),
// so just hardcode it instead of recursively searching for it.
const webAnimationsJs = 'bower_components/web-animations-js/web-animations-next-lite.min.js';
fs.copySync(webAnimationsJs, `${destinationRootPath}/${webAnimationsJs}`);
return '';
}).then(() => {
helpers.getAppReleasePaths('.').forEach(releasePath => {
const index = 'src/gui/html/index.html';
const destinationRootPath = `${releasePath.path}/resources/ui`;
const imports = new Set();
copyFiles(getRecursiveHtmlImports(index, imports), destinationRootPath);
copyFiles(getJavaScriptSources(index), destinationRootPath);
fs.copySync('src/gui/html/css', `${destinationRootPath}/css`);
fs.copySync('resources/ui/css/dark-theme.css', `${destinationRootPath}/css/dark-theme.css`);
fs.copySync(fontsPath, `${destinationRootPath}/fonts`);
copyNormalisedFile(index, `${destinationRootPath}/index.html`);
// This is the only JS file referenced by a HTML import (neon-animation),
// so just hardcode it instead of recursively searching for it.
const webAnimationsJs = 'bower_components/web-animations-js/web-animations-next-lite.min.js';
fs.copySync(webAnimationsJs, `${destinationRootPath}/${webAnimationsJs}`);
});
});
+26
View File
@@ -0,0 +1,26 @@
const fs = require('fs-extra');
const path = require('path');
const request = require('request');
const decompress = require('decompress');
const decompressUnzip = require('decompress-unzip');
function getRobotoFiles(url, destinationPath) {
const extractPath = path.dirname(destinationPath);
const downloadPath = path.join(extractPath, 'roboto-hinted.zip');
return new Promise((resolve, reject) => {
request(url)
.pipe(fs.createWriteStream(downloadPath))
.on('close', (err) => {
if (err) {
reject(err);
}
resolve();
});
}).then(() => decompress(downloadPath, extractPath)).then(() => {
fs.renameSync(path.join(extractPath, 'roboto-hinted'), destinationPath);
fs.removeSync(downloadPath);
});
}
module.exports.getRobotoFiles = getRobotoFiles;