mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +00:00
Re-apply desktop native debug log level debug builds and fix build workflow (#17908)
* Reapply "Desktop Native compile debug builds with debug log level (#17357)" (#17815) This reverts commit5386b58f23. * Use release mode if workflow called from upstream * fix bug in build script * revert napi build command to not use --release * forward caller's args to napi * js things * shell thangs * use platform agnostic expansion * Revert "use platform agnostic expansion" This reverts commit5ee629f822. * powershell expansion
This commit is contained in:
20
.github/workflows/build-desktop.yml
vendored
20
.github/workflows/build-desktop.yml
vendored
@@ -583,7 +583,9 @@ jobs:
|
||||
- name: Build Native Module
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
working-directory: apps/desktop/desktop_native
|
||||
run: node build.js cross-platform
|
||||
env:
|
||||
MODE: ${{ github.event_name == 'workflow_call' && '--release' || '' }}
|
||||
run: node build.js cross-platform "$env:MODE"
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
@@ -846,7 +848,9 @@ jobs:
|
||||
- name: Build Native Module
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
working-directory: apps/desktop/desktop_native
|
||||
run: node build.js cross-platform
|
||||
env:
|
||||
MODE: ${{ github.event_name == 'workflow_call' && '--release' || '' }}
|
||||
run: node build.js cross-platform "$env:MODE"
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
@@ -1202,7 +1206,9 @@ jobs:
|
||||
- name: Build Native Module
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
working-directory: apps/desktop/desktop_native
|
||||
run: node build.js cross-platform
|
||||
env:
|
||||
MODE: ${{ github.event_name == 'workflow_call' && '--release' || '' }}
|
||||
run: node build.js cross-platform "$MODE"
|
||||
|
||||
- name: Build application (dev)
|
||||
run: npm run build
|
||||
@@ -1424,7 +1430,9 @@ jobs:
|
||||
- name: Build Native Module
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
working-directory: apps/desktop/desktop_native
|
||||
run: node build.js cross-platform
|
||||
env:
|
||||
MODE: ${{ github.event_name == 'workflow_call' && '--release' || '' }}
|
||||
run: node build.js cross-platform "$MODE"
|
||||
|
||||
- name: Build
|
||||
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||
@@ -1705,7 +1713,9 @@ jobs:
|
||||
- name: Build Native Module
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
working-directory: apps/desktop/desktop_native
|
||||
run: node build.js cross-platform
|
||||
env:
|
||||
MODE: ${{ github.event_name == 'workflow_call' && '--release' || '' }}
|
||||
run: node build.js cross-platform "$MODE"
|
||||
|
||||
- name: Build
|
||||
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||
|
||||
@@ -113,8 +113,8 @@ if (process.platform === "linux") {
|
||||
|
||||
platformTargets.forEach(([target, _]) => {
|
||||
installTarget(target);
|
||||
buildNapiModule(target);
|
||||
buildProxyBin(target);
|
||||
buildImporterBinaries(target);
|
||||
buildNapiModule(target, mode === "release");
|
||||
buildProxyBin(target, mode === "release");
|
||||
buildImporterBinaries(target, mode === "release");
|
||||
buildProcessIsolation();
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"version": "0.1.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"build": "napi build --platform --no-js",
|
||||
"build": "node scripts/build.js",
|
||||
"test": "cargo test"
|
||||
},
|
||||
"author": "",
|
||||
|
||||
22
apps/desktop/desktop_native/napi/scripts/build.js
Normal file
22
apps/desktop/desktop_native/napi/scripts/build.js
Normal file
@@ -0,0 +1,22 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
const isRelease = args.includes('--release');
|
||||
|
||||
const argsString = args.join(' ');
|
||||
|
||||
if (isRelease) {
|
||||
console.log('Building release mode.');
|
||||
|
||||
execSync(`napi build --platform --no-js ${argsString}`, { stdio: 'inherit'});
|
||||
|
||||
} else {
|
||||
console.log('Building debug mode.');
|
||||
|
||||
execSync(`napi build --platform --no-js ${argsString}`, {
|
||||
stdio: 'inherit',
|
||||
env: { ...process.env, RUST_LOG: 'debug' }
|
||||
});
|
||||
}
|
||||
@@ -994,7 +994,7 @@ pub mod logging {
|
||||
};
|
||||
use tracing::Level;
|
||||
use tracing_subscriber::{
|
||||
filter::{EnvFilter, LevelFilter},
|
||||
filter::EnvFilter,
|
||||
fmt::format::{DefaultVisitor, Writer},
|
||||
layer::SubscriberExt,
|
||||
util::SubscriberInitExt,
|
||||
@@ -1082,9 +1082,17 @@ pub mod logging {
|
||||
pub fn init_napi_log(js_log_fn: ThreadsafeFunction<FnArgs<(LogLevel, String)>>) {
|
||||
let _ = JS_LOGGER.0.set(js_log_fn);
|
||||
|
||||
// the log level hierarchy is determined by:
|
||||
// - if RUST_LOG is detected at runtime
|
||||
// - if RUST_LOG is provided at compile time
|
||||
// - default to INFO
|
||||
let filter = EnvFilter::builder()
|
||||
// set the default log level to INFO.
|
||||
.with_default_directive(LevelFilter::INFO.into())
|
||||
.with_default_directive(
|
||||
option_env!("RUST_LOG")
|
||||
.unwrap_or("info")
|
||||
.parse()
|
||||
.expect("should provide valid log level at compile time."),
|
||||
)
|
||||
// parse directives from the RUST_LOG environment variable,
|
||||
// overriding the default directive for matching targets.
|
||||
.from_env_lossy();
|
||||
|
||||
Reference in New Issue
Block a user