Skip to content

Commit

Permalink
Merge pull request #234 from cosmos/fabo/51-build-windows
Browse files Browse the repository at this point in the history
added windows build
  • Loading branch information
jbibla authored Dec 13, 2017
2 parents 0c5f8ba + 9f0c9cd commit c41a73d
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 201 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ When you are testing the build system you can skip the repackaging of the JS fil
$ npm run build -- --skip-pack
```

### Build on Windows

- Install [golang](`https://golang.org/dl/`)
- Install [glide](`https://github.com/Masterminds/glide/releases`)

- Install [node](`https://nodejs.org/en/download/`)
- Install Yarn: `$ npm i -g yarn`
- Install Microsoft build tools: `$ npm install --global --production windows-build-tools`
- Set build tools to needed version `yarn config set msvs_version 2015 --global`

- Install [GNU MAKE](`http://gnuwin32.sourceforge.net/packages/make.htm`)
- Install [MinGW64](`https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download`)
- Add MAKE and MinGW64 to the PATH environment variable ([HOW TO](https://msdn.microsoft.com/de-de/library/windows/desktop/bb776899(v=vs.85).aspx))
- MAKE should be at `C:\Program Files (x86)\GnuWin32\bin`
- MinGW64 you have to look up at `C:\Program Files\mingw-w64\{{version}}\mingw64\bin`

- Pack the electron application: `$ npm run build:win32`
- Build the Setup: `$ npm run release:win32`
- The installer will be under `./builds/cosmos/Cosmos-win32`

## Testing

To test you need to first package the web content of the app, as this content can only be used bundled by the electron instance.
Expand Down
3 changes: 3 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@
"babel-runtime": "^6.26.0",
"create-hash": "^1.1.3",
"prebuild-install": "^2.1.2"
},
"optionalDependencies": {
"electron-squirrel-startup": "^1.0.0"
}
}
33 changes: 8 additions & 25 deletions app/src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,31 +130,7 @@ function createWindow () {
webContents.on('will-navigate', handleRedirect)
webContents.on('new-window', handleRedirect)

// setup menu to handle copy/paste, etc
var template = [
{
label: 'Cosmos UI',
submenu: [
{ label: 'About Cosmos UI', selector: 'orderFrontStandardAboutPanel:' },
{ type: 'separator' },
{ label: 'Quit', accelerator: 'Command+Q', click: () => app.quit() }
]
},
{
label: 'Edit',
submenu: [
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
{ type: 'separator' },
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:' }
]
}
]

Menu.setApplicationMenu(Menu.buildFromTemplate(template))
Menu.setApplicationMenu(null)
}

function startProcess (name, args, env) {
Expand Down Expand Up @@ -334,6 +310,13 @@ function consistentConfigDir (versionPath, genesisPath, configPath) {
}

async function main () {
// the windows installer opens the app once when installing
// the package recommends, that we exit if this happens
// we can also react to installer events, but currently don't need to
if (require('electron-squirrel-startup')) {
return
}

if (JSON.parse(process.env.COSMOS_UI_ONLY || 'false')) {
return
}
Expand Down
8 changes: 7 additions & 1 deletion app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ dashdash@^1.12.0:
dependencies:
assert-plus "^1.0.0"

[email protected]:
[email protected], debug@^2.2.0:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
dependencies:
Expand Down Expand Up @@ -531,6 +531,12 @@ [email protected]:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"

electron-squirrel-startup@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/electron-squirrel-startup/-/electron-squirrel-startup-1.0.0.tgz#19b4e55933fa0ef8f556784b9c660f772546a0b8"
dependencies:
debug "^2.2.0"

elliptic@^6.2.3:
version "6.4.0"
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.4.0.tgz#cac9af8762c85836187003c8dfe193e5e2eae5df"
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"build:win32": "cross-env PLATFORM_TARGET=win32 node tasks/release.js",
"release:darwin": "electron-installer-dmg --overwrite builds/Cosmos-darwin-x64/Cosmos.app builds/cosmos",
"release:linux": "electron-installer-debian --src builds/Cosmos-linux-x64/ --dest builds/cosmos --arch amd64",
"release:win32": "node tasks/windows-installer.js",
"uionly": "cross-env COSMOS_UI_ONLY='true' yarn run testnet",
"local": "npm run testnet local",
"testnet": "node tasks/testnet.js",
Expand Down Expand Up @@ -54,8 +55,6 @@
"devtron": "^1.1.0",
"electron-debug": "^1.4.0",
"electron-devtools-installer": "^2.1.0",
"electron-installer-debian": "^0.7.1",
"electron-installer-dmg": "^0.2.1",
"electron-packager": "^10.1.0",
"electron-rebuild": "^1.5.7",
"eslint": "^3.13.1",
Expand Down Expand Up @@ -180,5 +179,10 @@
"./test/unit/helpers/fixed_time.js",
"./test/unit/helpers/setup.js"
]
},
"optionalDependencies": {
"electron-installer-debian": "^0.7.1",
"electron-installer-dmg": "^0.2.1",
"electron-winstaller": "^2.6.3"
}
}
17 changes: 17 additions & 0 deletions tasks/windows-installer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var electronInstaller = require('electron-winstaller');
var package = require('../package.json')

// Installer is customizable: https://github.com/electron/windows-installer
let resultPromise = electronInstaller.createWindowsInstaller({
appDirectory: './builds/Cosmos-win32-x64',
outputDirectory: './builds/cosmos/Cosmos-win32',
title: 'Cosmos',
authors: package.author,
exe: 'Cosmos.exe',
setupExe: `Cosmos-Setup-v${package.version}.exe`,
iconUrl: 'https://github.com/cosmos/cosmos-ui/raw/develop/app/icons/icon.ico',
setupIcon: './app/icons/icon.ico',
noMsi: true
});

return resultPromise.then(() => console.log("It worked!"), (e) => console.log(`No dice: ${e.message}`));
Loading

0 comments on commit c41a73d

Please sign in to comment.