Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
build for windows
  • Loading branch information
Alexey Smirnov committed Jun 2, 2020
1 parent 09cd59d commit feee0dc
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/e3kit-browser/package.json
Expand Up @@ -16,7 +16,7 @@
"author": "Virgil Security Inc. <support@virgilsecurity.com>",
"license": "BSD-3-Clause",
"scripts": {
"build": "node --max-old-space-size=4096 node_modules/.bin/rollup -c",
"build": "cross-env NODE_OPTIONS=--max-old-space-size=4096 rollup -c",
"clean": "rimraf .rpt2_cache dist",
"prepare": "npm run clean && npm run build"
},
Expand All @@ -29,6 +29,7 @@
"virgil-sdk": "^6.1.1"
},
"devDependencies": {
"cross-env": "^7.0.2",
"rimraf": "^3.0.0",
"rollup": "^1.29.1",
"rollup-plugin-commonjs": "^10.1.0",
Expand Down
19 changes: 14 additions & 5 deletions packages/e3kit-browser/rollup.config.js
Expand Up @@ -9,7 +9,7 @@ const nodeGlobals = require('rollup-plugin-node-globals');
const nodeResolve = require('rollup-plugin-node-resolve');
const replace = require('rollup-plugin-re');
const typescript = require('rollup-plugin-typescript2');

const { generateCrossPlatformPath } = require('../../utils/build');
const packageJson = require('./package.json');
const PRODUCT_NAME = 'e3kit';

Expand Down Expand Up @@ -49,21 +49,30 @@ const getCryptoEntryPointName = (target, cryptoType, format) =>
const createEntry = (target, cryptoType, format) => {
const foundationModuleName = 'virgil-crypto';
const foundationPath = getModulePath(foundationModuleName);
const foundationEntryPoint = path.join(
const foundationEntryPoint = generateCrossPlatformPath(
foundationModuleName,
'dist',
getCryptoEntryPointName(target, cryptoType, FORMAT.ES),
);
const foundationWasmPath = path.join(foundationPath, 'dist', `libfoundation.${target}.wasm`);

const foundationWasmPath = generateCrossPlatformPath(
foundationPath,
'dist',
`libfoundation.${target}.wasm`,
);

const pythiaModuleName = '@virgilsecurity/pythia-crypto';
const pythiaPath = getModulePath(pythiaModuleName);
const pythiaEntryPoint = path.join(
const pythiaEntryPoint = generateCrossPlatformPath(
pythiaModuleName,
'dist',
getCryptoEntryPointName(target, cryptoType, FORMAT.ES),
);
const pythiaWasmPath = path.join(pythiaPath, 'dist', `libpythia.${target}.wasm`);
const pythiaWasmPath = generateCrossPlatformPath(
pythiaPath,
'dist',
`libpythia.${target}.wasm`,
);

return {
external: format !== FORMAT.UMD ? [foundationEntryPoint, pythiaEntryPoint] : [],
Expand Down
5 changes: 3 additions & 2 deletions packages/e3kit-node/rollup.config.js
Expand Up @@ -5,6 +5,7 @@ const license = require('rollup-plugin-license');
const replace = require('rollup-plugin-re');
const typescript = require('rollup-plugin-typescript2');
const json = require('@rollup/plugin-json');
const { generateCrossPlatformPath } = require('../../utils/build');

const packageJson = require('./package.json');

Expand All @@ -26,14 +27,14 @@ const getCryptoEntryPointName = (cryptoType, format) =>

const createEntry = (cryptoType, format) => {
const foundationModuleName = 'virgil-crypto';
const foundationEntryPoint = path.join(
let foundationEntryPoint = generateCrossPlatformPath(
foundationModuleName,
'dist',
getCryptoEntryPointName(cryptoType, format),
);

const pythiaModuleName = '@virgilsecurity/pythia-crypto';
const pythiaEntryPoint = path.join(
const pythiaEntryPoint = generateCrossPlatformPath(
pythiaModuleName,
'dist',
getCryptoEntryPointName(cryptoType, format),
Expand Down
2 changes: 1 addition & 1 deletion packages/e3kit-tests/src/node/EThree.test.ts
Expand Up @@ -49,7 +49,7 @@ describe.only('EThree initialization', () => {

it('should initialize with custom group name', () => {
EThree.initialize(createFetchToken(uuid()), {
groupStorageName: `C:/program files/${uuid()}`,
groupStorageName: `d:/program files/${uuid()}`,
});
});
});
13 changes: 13 additions & 0 deletions utils/build.js
@@ -0,0 +1,13 @@
const path = require('path');

const generateCrossPlatformPath = (...args) => {
let result = path.join.apply(null, args);

if (process.platform === 'win32') {
result = result.replace(/\\/g, '/');
}

return result;
};

module.exports = { generateCrossPlatformPath };

0 comments on commit feee0dc

Please sign in to comment.