mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-01-18 13:07:58 +00:00
Added a build script to simplify compiling Rolens from source
This commit is contained in:
parent
1c95b86475
commit
05bfd54fb5
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -72,6 +72,9 @@ jobs:
|
||||
name: rolens-${{ matrix.platform }}
|
||||
path: releases/*
|
||||
|
||||
- name: Test build script for users
|
||||
run: ./build.js
|
||||
|
||||
bundle:
|
||||
name: Bundle artifacts
|
||||
runs-on: ubuntu-22.04
|
||||
|
12
INSTALL.md
12
INSTALL.md
@ -11,11 +11,17 @@ Rolens can run on the following operating systems:
|
||||
|
||||
## Pre-compiled binaries
|
||||
|
||||
You can obtain a pre-compiled Rolens binary for macOS or installer for Windows from the [release page](https://github.com/garraflavatra/rolens/releases/latest).
|
||||
You can obtain a pre-compiled Rolens.app for macOS or installer for Windows from the [release page](https://github.com/garraflavatra/rolens/releases/latest).
|
||||
|
||||
## From source
|
||||
If you use a Linux-based OS, please continue reading.
|
||||
|
||||
Rolens is open-source software, which means that you can compile it from source on your own machine by cloning [the repository](https://github.com/garraflavatra/rolens).
|
||||
## Compile from source in 2 easy steps
|
||||
|
||||
Rolens is free and open-source software, which means that you can compile it from source on your own machine by cloning [the repository](https://github.com/garraflavatra/rolens).
|
||||
|
||||
If you have Node.js installed, just download the source from GitHub, and run `./build.js`. The install script will check that dependencies are present and build Rolens for you. If you want to build it yourself, please continue reading.
|
||||
|
||||
## Advanced build
|
||||
|
||||
### Prerequisites
|
||||
|
||||
|
@ -36,7 +36,9 @@ You can obtain a pre-compiled Rolens binary for macOS or installer for Windows f
|
||||
|
||||
### Compiling from source
|
||||
|
||||
Please refer to [the documentation](https://garraflavatra.github.io/rolens/installation/) for detailed compilation instructions.
|
||||
If you have Node.js installed, just download the source from GitHub, and run `./build.js`. The install script will check that dependencies are present and build Rolens for you.
|
||||
|
||||
If you want to build it yourself, please refer to [the documentation](https://garraflavatra.github.io/rolens/installation/) for detailed compilation instructions.
|
||||
|
||||
## User guide
|
||||
|
||||
@ -50,6 +52,8 @@ Rolens is designed to be as intuitive as possible. But if something is unclear n
|
||||
|
||||
Feel free to contact me if you have questions! [Send an e-mail.](mailto:romein@vburen.nl)
|
||||
|
||||
## Con
|
||||
|
||||
## Author and license
|
||||
|
||||
© [Romein van Buren](mailto:romein@vburen.nl) 2023. The source code and compiled binaries are released under the GNU GPLv3 license — see [`LICENSE`](./LICENSE) for the full license text.
|
||||
|
137
build.js
Executable file
137
build.js
Executable file
@ -0,0 +1,137 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const { execSync, spawn } = require('child_process');
|
||||
const { readFileSync, statSync, rmdirSync } = require('fs');
|
||||
|
||||
// Check that the script is run from the root.
|
||||
|
||||
try {
|
||||
const wailsJsonFile = statSync('./wails.json');
|
||||
if (!wailsJsonFile.isFile()) {
|
||||
throw new Error();
|
||||
}
|
||||
} catch {
|
||||
console.log('Error: please run the build script from the Rolens project root.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Output version.
|
||||
|
||||
const version = JSON.parse(readFileSync('./wails.json').toString()).info.productVersion;
|
||||
|
||||
if (process.argv.includes('-v') || process.argv.includes('-version') || process.argv.includes('--version')) {
|
||||
console.log(version);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// Output help text.
|
||||
|
||||
if (process.argv.includes('-h') || process.argv.includes('--help')) {
|
||||
console.log(`Rolens build script v${version}`);
|
||||
console.log('');
|
||||
console.log('This script installs missing dependencies if any, and then compiles Rolens');
|
||||
console.log('for the current platform.');
|
||||
console.log('');
|
||||
console.log('Options:');
|
||||
console.log(' -h --help Show this help text and exit.');
|
||||
console.log(' -q --quiet Do not output Wails build log.');
|
||||
console.log(' -v --version Log the current Rolens version and exit.');
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// Shared objects.
|
||||
|
||||
const quiet = process.argv.includes('-q') || process.argv.includes('--quiet');
|
||||
const isWindows = process.platform === 'win32';
|
||||
const missingDependencies = [];
|
||||
|
||||
function isNullish(val) {
|
||||
return val === undefined || val === null;
|
||||
}
|
||||
|
||||
// Check that Go ^1.18 is installed.
|
||||
|
||||
const goMinorVersion = /go1\.([0-9][0-9])/.exec(
|
||||
execSync('go version').toString()
|
||||
)?.pop();
|
||||
|
||||
|
||||
if (isNullish(goMinorVersion) || (parseInt(goMinorVersion) < 18)) {
|
||||
missingDependencies.push({ name: 'Go ^1.18 ^16', url: 'https://go.dev/doc/install' });
|
||||
}
|
||||
|
||||
// Check that Node.js ^16 is installed.
|
||||
|
||||
const nodeMajorVersion = /v([0-9]{1,2})\.[0-9]{1,3}\.[0-9]{1,3}/.exec(
|
||||
execSync('node --version').toString()
|
||||
)?.pop();
|
||||
|
||||
if (isNullish(nodeMajorVersion) || (parseInt(nodeMajorVersion) < 16)) {
|
||||
missingDependencies.push({ name: 'Node.js ^16', url: 'https://go.dev/doc/install' });
|
||||
}
|
||||
|
||||
// Check that Wails is installed.
|
||||
|
||||
const wailsMinorVersion = /v2\.([0-9])\.[0-9]/.exec(
|
||||
execSync('wails version').toString()
|
||||
)?.pop();
|
||||
|
||||
if (isNullish(wailsMinorVersion) || (parseInt(wailsMinorVersion) < 3)) {
|
||||
missingDependencies.push({
|
||||
name: 'Wails ^2.3',
|
||||
command: 'go install github.com/wailsapp/wails/v2/cmd/wails@latest',
|
||||
url: 'https://wails.io/docs/gettingstarted/installation',
|
||||
});
|
||||
}
|
||||
|
||||
// Check that NSIS is installed on Windows.
|
||||
|
||||
if (isWindows) {
|
||||
const nsisInstalled = /v3\.([0-9][0-9])/.test(execSync('makensis.exe /VERSION').toString());
|
||||
if (!nsisInstalled) {
|
||||
missingDependencies.push({ name: 'Nullsoft Install System ^3', url: 'https://nsis.sourceforge.io/Download' });
|
||||
}
|
||||
}
|
||||
|
||||
// Report missing dependencies.
|
||||
|
||||
if (missingDependencies.length > 0) {
|
||||
console.log('You are missing the following dependencies:');
|
||||
|
||||
for (const dependency of missingDependencies) {
|
||||
console.log('');
|
||||
console.log(`- ${dependency.name}`);
|
||||
|
||||
if (dependency.command) {
|
||||
console.log(' Install it by executing:');
|
||||
console.log(` ${dependency.command}`);
|
||||
}
|
||||
|
||||
if (dependency.url) {
|
||||
console.log(' Visit the following page for more information:');
|
||||
console.log(` ${dependency.url}`);
|
||||
}
|
||||
}
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Clean output directory.
|
||||
|
||||
console.log('Cleaning output directory...');
|
||||
try { rmdirSync('./build/bin'); } catch {}
|
||||
|
||||
// Build Rolens.
|
||||
|
||||
console.log(`Building Rolens ${version}...`);
|
||||
console.log();
|
||||
|
||||
const proc = spawn('wails', [ 'build', '-clean', isWindows ? '-nsis' : '' ]);
|
||||
|
||||
if (!quiet) {
|
||||
proc.stdout.on('data', data => process.stdout.write(data));
|
||||
proc.stderr.on('data', data => process.stderr.write(data));
|
||||
}
|
||||
|
||||
proc.on('exit', code => process.exit(code));
|
Loading…
Reference in New Issue
Block a user