Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Apr 1, 2024
1 parent f58ca71 commit b6d4476
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 100 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: build

on: [push, pull_request]

jobs:
build:
runs-on: >-
${{
(matrix.targetOs == 'mac' && matrix.targetArch == 'x64') &&
'macos-13' ||
(fromJson('{"linux":"ubuntu-22.04","mac":"macos-14","win":"windows-2022"}')[matrix.targetOs])
}}
continue-on-error: false

strategy:
fail-fast: false
matrix:
targetOs: [linux, mac, win]
targetArch: [x64]
include:
- targetOs: mac
targetArch: arm64
- targetOs: win
targetArch: x86

steps:
- name: Install Linux Dependencies
if: matrix.targetOs == 'linux'
run: |
sudo apt update
sudo apt install -y cmake libgtk-3-dev libnotify-dev libwebkit2gtk-4.0-dev
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang 100
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- name: Checkout
uses: actions/checkout@v4

- nmae: Build
run: yarn && yarn dist
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.swp
*.zip

yarn.lock
package-lock.json
npm-debug.log
node_modules
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ cmake_minimum_required(VERSION 3.13)

if(APPLE)
# Target macOS version.
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10)
set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0)
elseif(WIN32)
# Use Windows 10 SDK.
set(CMAKE_SYSTEM_VERSION 10.0)
endif()

# Project name and executable name.
project(muban)
set(APP_NAME "muban")
project(boilerplate)
set(APP_NAME "boilerplate")

# The main executable.
file(GLOB SRC_FILES "src/*.h" "src/*.cc" "src/*.rc" "src/*.xml" "src/*.ico")
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Muban
# boilerplate-cpp

A template of the [Yue library](https://github.com/yue/yue) for building
A C++ template of the [Yue library](https://github.com/yue/yue) for building
cross-platform desktop apps with system webview and native GUI widgets.

## Features
Expand Down Expand Up @@ -29,10 +29,10 @@ cross-platform desktop apps with system webview and native GUI widgets.

## Docs

* [Architecture of Muban](https://github.com/yue/muban/blob/master/docs/architecture.md)
* [Add native bindings to web pages](https://github.com/yue/muban/blob/master/docs/native_bindings.md)
* [Custom protocol](https://github.com/yue/muban/blob/master/docs/custom_protocol.md)
* [Yue documents (external link)](http://libyue.com/docs/v0.3.1/cpp/)
* [Architecture](https://github.com/yue/boilerplate-cpp/blob/master/docs/architecture.md)
* [Add native bindings to web pages](https://github.com/yue/boilerplate-cpp/blob/master/docs/native_bindings.md)
* [Custom protocol](https://github.com/yue/boilerplate-cpp/blob/master/docs/custom_protocol.md)
* [Yue documents (external link)](http://libyue.com/docs/latest/cpp/)

## License

Expand Down
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</head>
<body>
<div id="result"></div>
<div id="button" onclick="muban.showSysInfo('cpu')">Show CPU Info</div>
<div id="button" onclick="boilerplate.showSysInfo('cpu')">Show CPU Info</div>
<script type="text/javascript" charset="utf-8">
window.report = function(message) {
document.getElementById('result').textContent = message
Expand Down
12 changes: 0 additions & 12 deletions azure-pipelines-template.yml

This file was deleted.

43 changes: 0 additions & 43 deletions azure-pipelines.yml

This file was deleted.

27 changes: 12 additions & 15 deletions docs/architecture.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Architecture of Muban
# Architecture of boilerplate-cpp

Muban is a C++ project using CMake for building, Node.js is also used for the
build scripts.
This project uses CMake for building, and uses Node.js as build scripts.

## Source code structure

Expand All @@ -16,26 +15,26 @@ build scripts.

## System requirements

The Yue library requires C++14 for building, so newer toolchains are required.
The Yue library requires C++20 for building, so newer toolchains are required.

* Linux:
* GCC >=6 or clang
* GCC >=10 or clang
* libstdc++6 or newer
* libwebkit2gtk >= 2.8
* Node.js >= 8
* Node.js >= 20
* macOS:
* Xcode >= 8.3
* The OS X 10.12 SDK
* Node.js >= 8
* Xcode >= 15
* macOS SDK >= 11
* Node.js >= 20
* Windows:
* Visual Studio 2017 Update 3.2 with the 15063 (Creators Update) Windows SDK
* An x64 machine with Node.js x64 >= 8 installed.
* Visual Studio 2022 with Windows 10 SDK
* An x64 machine with Node.js x64 >= 20 installed.

Note that on Linux due to using libstdc++6 and libwebkit2gtk 2.8, the generated
binary can only run on newer distributions, e.g. at least Ubuntu 16.04 and
Debian Stretch.

On macOS due to using the `WKWebView` API, only macOS 10.10 and later are
On macOS due to using the `WKWebView` API, only macOS 11.0 and later are
supported.

On Windows currently Windows Vista and later are supported. It should be
Expand Down Expand Up @@ -74,7 +73,7 @@ Note that devtools are currently only available on Linux and macOS.
## IDE support

With the power of `cmake`, on macOS a Xcode project will be generated, and on
Windows a Visual Studio 2017 solution will be generated. So you can develop your
Windows a Visual Studio 2022 solution will be generated. So you can develop your
application with the IDEs on macOS and Windows.

Also note that due to limitations of `cmake`, we can only build for one CPU
Expand All @@ -91,8 +90,6 @@ For Windows you can set the `npm_config_arch` environment variable to specify
the architecture to build for (`x64` or `ia32`), if not set the target
architecture would be determined by the value of `process.arch` from Node.js.

For macOS only `x64` target is supported.

## Packaging

In order to generate a single-file executable, the `app/` files are archived
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "muban",
"name": "boilerplate",
"private": true,
"version": "0.1.0",
"description": "Build desktop apps with system webview and native controls",
"scripts": {
"start": "node scripts/run.js",
"install": "npm run download && npm run bootstrap && npm run build",
"download": "node scripts/download_libyue.js v0.9.1",
"download": "node scripts/download_libyue.js v0.15.1",
"bootstrap": "node scripts/bootstrap.js",
"build": "node scripts/build.js",
"dist": "node scripts/dist.js"
Expand All @@ -17,9 +17,9 @@
},
"license": "public domain",
"devDependencies": {
"@zcbenz/cmake-binaries": "1.3.17-2",
"asar": "3.x",
"download-yue": "2.x",
"yazl": "2.4.3"
"@electron/asar": "3.2.9",
"@indutny/yazl": "2.7.0",
"@yogalayout/cmake-bin": "3.28.0-1",
"download-yue": "2.x"
}
}
2 changes: 1 addition & 1 deletion scripts/asar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const crypto = require('crypto')
const fs = require('fs')
const asar = require('asar')
const asar = require('@electron/asar')

require('./common')

Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mkdir('out')
if (process.platform == 'win32') {
process.exit(spawnSync(cmake,
['-S', '.', '-B', 'out',
'-G', 'Visual Studio 16 2019',
'-G', 'Visual Studio 19 2022',
'-A', targetCpu == 'x64' ? 'x64' : 'Win32']).status)
} else {
mkdir('out/Release')
Expand Down
4 changes: 2 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const config = process.argv[2] ? process.argv[2] : 'Debug'

if (process.platform == 'win32') {
const vsPaths = [
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin',
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\MSBuild\\Current\\Bin',
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin',
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\Enterprise\\MSBuild\\Current\\Bin',
process.env.PATH
]
const env = Object.assign(process.env, {PATH: vsPaths.join(path.delimiter)})
Expand Down
9 changes: 3 additions & 6 deletions scripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ const targetCpu = {
}[narch]

// Find the path of cmake.
const cmakeRoot = path.resolve('node_modules', '@zcbenz', 'cmake-binaries', 'bin2')
const cmake = {
darwin: path.join(cmakeRoot, 'CMake.app', 'Contents', 'bin', 'cmake'),
linux: path.join(cmakeRoot, 'bin', 'cmake'),
win32: path.join(cmakeRoot, 'bin', 'cmake.exe'),
}[process.platform]
let cmake = path.resolve('node_modules', '@yogalayout', 'cmake-bin', 'bin', 'cmake')
if (process.platform == 'win')
cmake += '.exe'

// Make dir and ignore error.
function mkdir(dir) {
Expand Down
8 changes: 4 additions & 4 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static base::FilePath g_app_path;

// Handle custom protocol.
nu::ProtocolJob* CustomProtocolHandler(const std::string& url) {
std::string path = url.substr(sizeof("muban://app/") - 1);
std::string path = url.substr(sizeof("boilerplate://app/") - 1);
nu::ProtocolAsarJob* job = new nu::ProtocolAsarJob(g_app_path, path);
job->SetDecipher(std::string(ENCRYPTION_KEY, sizeof(ENCRYPTION_KEY)),
std::string("yue is good lib!"));
Expand Down Expand Up @@ -129,8 +129,8 @@ int main(int argc, const char *argv[]) {
#endif

// Set webview bindings and custom protocol.
nu::Browser::RegisterProtocol("muban", &CustomProtocolHandler);
browser->SetBindingName("muban");
nu::Browser::RegisterProtocol("boilerplate", &CustomProtocolHandler);
browser->SetBindingName("boilerplate");
browser->AddBinding("showSysInfo", &ShowSysInfo);

// Show window when page is loaded.
Expand All @@ -141,7 +141,7 @@ int main(int argc, const char *argv[]) {
// Only activate for the first time.
self->on_finish_navigation.Disconnect(id);
});
browser->LoadURL("muban://app/index.html");
browser->LoadURL("boilerplate://app/index.html");

// Enter message loop.
nu::MessageLoop::Run();
Expand Down

0 comments on commit b6d4476

Please sign in to comment.