Skip to content

Commit

Permalink
Bundle examples with webpack
Browse files Browse the repository at this point in the history
This makes sure that they are available during runtime.
Use _dirname instead of module.path as the latter doesn't work.

Contributed on behalf of STMicroelectronics
  • Loading branch information
sgraband committed Sep 19, 2023
1 parent 299c146 commit bae2af9
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@
tracecompass-server
nohup.out

applications/**/resources/clangd-contexts
applications/**/resources/cmake-example
applications/**/resources/example-traces

**/workspace
17 changes: 17 additions & 0 deletions applications/browser/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// @ts-check
const config = require('./gen-webpack.config.js');
const backend = require('./gen-webpack.node.config.js');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const resolvePackagePath = require('resolve-package-path');

/**
* Expose bundled modules on window.theia.moduleName namespace, e.g.
Expand All @@ -20,6 +23,20 @@ if (process.platform !== 'win32') {
backend.ignoredResources.add('@vscode/windows-ca-certs/build/Release/crypt32.node');
}

// Copy example resources
const plugin =
new CopyWebpackPlugin({
patterns: [
{
// copy examples to resource folder
from: path.join(resolvePackagePath('@eclipse-cdt-cloud/blueprint-examples', __dirname), '..', 'resources'),
to: path.resolve(__dirname, 'resources')
}
]
});

config[0].plugins.push(plugin);

module.exports = [
...config,
backend.config
Expand Down
28 changes: 27 additions & 1 deletion applications/docker/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
*/
// @ts-check
const config = require('./gen-webpack.config.js');
const backend = require('./gen-webpack.node.config.js');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const resolvePackagePath = require('resolve-package-path');

/**
* Expose bundled modules on window.theia.moduleName namespace, e.g.
Expand All @@ -14,4 +18,26 @@ config.module.rules.push({
loader: require.resolve('@theia/application-manager/lib/expose-loader')
}); */

module.exports = config;
if (process.platform !== 'win32') {
// For some reason, blueprint wants to bundle the `.node` files directly without going through `@vscode/windows-ca-certs`
backend.ignoredResources.add('@vscode/windows-ca-certs/build/Release/crypt32.node');
}

// Copy example resources
const plugin =
new CopyWebpackPlugin({
patterns: [
{
// copy examples to resource folder
from: path.join(resolvePackagePath('@eclipse-cdt-cloud/blueprint-examples', __dirname), '..', 'resources'),
to: path.resolve(__dirname, 'resources')
}
]
});

config[0].plugins.push(plugin);

module.exports = [
...config,
backend.config
];
16 changes: 16 additions & 0 deletions applications/electron/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// @ts-check
const config = require('./gen-webpack.config.js');
const backend = require('./gen-webpack.node.config.js');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const resolvePackagePath = require('resolve-package-path');

/**
* Expose bundled modules on window.theia.moduleName namespace, e.g.
Expand All @@ -20,6 +23,19 @@ if (process.platform !== 'win32') {
backend.ignoredResources.add('@vscode/windows-ca-certs/build/Release/crypt32.node');
}

// Copy example resources
const plugin =
new CopyWebpackPlugin({
patterns: [
{
// copy examples to resource folder
from: path.join(resolvePackagePath('@eclipse-cdt-cloud/blueprint-examples', __dirname), '..', 'resources'),
to: path.resolve(__dirname, 'resources')
}
]
});

config[0].plugins.push(plugin);

module.exports = [
...config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class CdtCloudBlueprintExamplesContribution implements ExamplesContributi
id: CdtCloudBlueprintExamples.CMAKE_EXAMPLE,
label: 'CMake example',
welcomeFile: 'CMAKE_EXAMPLE_README.md',
resourcesPath: new URI(module.path).resolve('../../resources/cmake-example').normalizePath().toString(),
resourcesPath: new URI(__dirname).resolve('../../resources/cmake-example').normalizePath().toString(),
launches: (options: ExampleOptions) => [{
'type': 'gdb',
'request': 'launch',
Expand Down

0 comments on commit bae2af9

Please sign in to comment.