Skip to content
Snippets Groups Projects
Commit ba37754b authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[ivette] configure package loader

parent 89e947c1
No related branches found
No related tags found
No related merge requests found
......@@ -11,5 +11,6 @@ yarn-error.log
/bin
/dist
/doc/html
/src/renderer/loader.ts
# --------------------------------------------------------------------------
......@@ -9,9 +9,9 @@ DOME_CUSTOM_ENTRIES= yes
COPYRIGHT=CEA LIST / LSL
# --------------------------------------------------------------------------
.PHONY: all app dev doc serve dist lint fixlint
.PHONY: all app dev pkg doc serve dist lint fixlint
all: lint app
all: pkg lint app
app: dome-app
dev: dome-dev
......@@ -27,6 +27,23 @@ tsc: dome-pkg dome-templ
yarn run typecheck
yarn run lint --fix --cache --cache-location .eslint-cache
# --------------------------------------------------------------------------
# --- Ivette Package Loader
# --------------------------------------------------------------------------
LOADER=src/renderer/loader.ts
PACKAGES=$(shell find src -name "pkg.json")
lint: pkg
app: pkg
dev: pkg
pkg: $(LOADER)
$(LOADER): $(PACKAGES) ./configure.js ./Makefile
@rm -f $(LOADER)
@echo "[Ivette] configure packages"
@node ./configure.js $(LOADER) $(PACKAGES)
@chmod -f a-w $(LOADER)
# --------------------------------------------------------------------------
# --- Frama-C API
# --------------------------------------------------------------------------
......
// --------------------------------------------------------------------------
// --- Configure Packages
// --- Called by [make pkg]
// --------------------------------------------------------------------------
const path = require('path');
const fs = require('fs');
const loader = process.argv[2];
const inputFiles = process.argv.slice(3);
const packages = new Map();
let buffer = '// Ivette Package Loader (generated)\n';
inputFiles.forEach((file) => {
try {
const pkgId = path.relative('./src',path.dirname(file));
const pkgSrc = fs.readFileSync(file, { encoding: 'UTF-8' });
const pkgJson = JSON.parse(pkgSrc);
packages.set(pkgId,pkgJson);
} catch(err) {
console.error(`[Dome] Error ${file}: ${err}`);
process.exit(1);
}
});
function depend(id) {
const pkg = packages.get(id);
if (pkg) configure(pkg,id);
}
function configure(pkg, id) {
if (!pkg.done) {
pkg.done = true;
for(let parent = id;;) {
parent = path.dirname(parent);
if (!parent || parent === '.') break;
depend(parent);
}
const { depends=[], main='.' } = pkg;
depends.forEach(depend);
console.log(`[Ivette] package ${id}`);
buffer += `import '${path.join(id,main)}';\n`;
}
}
packages.forEach(configure);
fs.writeFileSync(loader, buffer);
{
"name": "Frama-C"
}
{
"name": "Frama-C/Dive"
}
{
"name": "Frama-C/Eva"
}
......@@ -13,7 +13,7 @@ import * as Sidebar from 'dome/frame/sidebars';
import * as Controller from './Controller';
import * as Extensions from './Extensions';
import * as Laboratory from './Laboratory';
import './PackageLoader';
import './loader';
// --------------------------------------------------------------------------
// --- Main View
......
/* --------------------------------------------------------------------------*/
/* --- This file is intended to be generated ---*/
/* --------------------------------------------------------------------------*/
import 'frama-c';
import 'frama-c/plugins/eva';
import 'frama-c/plugins/dive';
/* --------------------------------------------------------------------------*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment