Skip to content

Commit 491ea5d

Browse files
committed
Fix multiple main function error and macOS build issues
- Consolidated multiple conditional main functions into single main with conditional blocks - Switched reqwest from rustls-tls to native-tls to fix ARM64 macOS ring crate compilation - Removed default web feature and updated CI to use explicit feature flags - Fixed conditional compilation guards for API client usage - Updated CI workflow to use --no-default-features with specific platform features
1 parent 5ca5bf7 commit 491ea5d

File tree

5 files changed

+59
-50
lines changed

5 files changed

+59
-50
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,34 @@ jobs:
6767
if: ${{ matrix.platform == 'web' }}
6868
run: |
6969
cd opensvm-dioxus
70-
cargo build --target wasm32-unknown-unknown --features web --release
70+
cargo build --target wasm32-unknown-unknown --features web --release --no-default-features
7171
72-
- name: Build for Desktop (macOS/Linux)
73-
if: ${{ matrix.platform == 'desktop' && matrix.os != 'windows-latest' }}
72+
- name: Build for Desktop (macOS)
73+
if: ${{ matrix.platform == 'desktop' && matrix.os == 'macos-latest' }}
7474
run: |
7575
cd opensvm-dioxus
76-
RUSTFLAGS="-C target-cpu=native" cargo build --features desktop --release
76+
RUSTFLAGS="-C target-cpu=native" cargo build --features desktop --release --no-default-features
77+
shell: bash
78+
79+
- name: Build for Desktop (Linux)
80+
if: ${{ matrix.platform == 'desktop' && matrix.os == 'ubuntu-22.04' }}
81+
run: |
82+
cd opensvm-dioxus
83+
RUSTFLAGS="-C target-cpu=native" cargo build --features desktop --release --no-default-features
7784
shell: bash
7885

7986
- name: Build for Desktop (Windows)
8087
if: ${{ matrix.platform == 'desktop' && matrix.os == 'windows-latest' }}
8188
run: |
8289
cd opensvm-dioxus
8390
$env:RUSTFLAGS="-C target-cpu=native"
84-
cargo build --features desktop --release
91+
cargo build --features desktop --release --no-default-features
8592
shell: pwsh
8693

8794
- name: Run tests
8895
run: |
8996
cd opensvm-dioxus
90-
cargo test --features ${{ matrix.platform }}
97+
cargo test --features ${{ matrix.platform }} --no-default-features
9198
9299
- name: Upload artifacts
93100
uses: actions/upload-artifact@v4
@@ -254,7 +261,7 @@ jobs:
254261
- name: Build for Android
255262
run: |
256263
cd opensvm-dioxus
257-
RUSTFLAGS="-C opt-level=3 -C lto=thin" cargo build --target aarch64-linux-android --features android --release
264+
RUSTFLAGS="-C opt-level=3 -C lto=thin" cargo build --target aarch64-linux-android --features android --release --no-default-features
258265
259266
- name: Upload Android artifact
260267
uses: actions/upload-artifact@v4

opensvm-dioxus/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ chrono = { version = "0.4.31", features = ["serde"] }
1515
uuid = { version = "1.4.1", features = ["v4"] }
1616

1717
# HTTP client for API calls
18-
reqwest = { version = "0.11.22", features = ["json", "rustls-tls"], default-features = false, optional = true }
18+
reqwest = { version = "0.11.22", features = ["json", "native-tls"], default-features = false, optional = true }
1919

2020
# Web dependencies
2121
dioxus-web = { version = "0.4.0", optional = true }
@@ -51,7 +51,7 @@ dioxus-mobile = { version = "0.4.0", optional = true }
5151
android_logger = { version = "0.13.1", optional = true }
5252

5353
[features]
54-
default = ["web"]
54+
default = []
5555
web = [
5656
"dioxus-web",
5757
"wasm-bindgen",

opensvm-dioxus/src/main.rs

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,57 @@ mod utils;
99

1010
use app::App;
1111

12-
#[cfg(feature = "web")]
1312
fn main() {
14-
// Initialize logger for web
15-
use log::Level;
16-
console_log::init_with_level(Level::Debug).expect("Failed to initialize logger");
17-
1813
// Apply platform-specific optimizations
1914
platform_optimizations::initialize();
2015

21-
// Launch the Dioxus app in a browser
22-
dioxus_web::launch(App);
23-
}
16+
#[cfg(feature = "web")]
17+
{
18+
// Initialize logger for web
19+
use log::Level;
20+
console_log::init_with_level(Level::Debug).expect("Failed to initialize logger");
2421

25-
#[cfg(feature = "desktop")]
26-
fn main() {
27-
// Initialize logger for desktop
28-
use dioxus_desktop::{Config, LogicalSize, WindowBuilder};
29-
use log::LevelFilter;
22+
// Launch the Dioxus app in a browser
23+
dioxus_web::launch(App);
24+
}
3025

31-
// Set up desktop logger
32-
simple_logger::SimpleLogger::new()
33-
.with_level(LevelFilter::Debug)
34-
.init()
35-
.expect("Failed to initialize logger");
26+
#[cfg(feature = "desktop")]
27+
{
28+
// Initialize logger for desktop
29+
use dioxus_desktop::{Config, LogicalSize, WindowBuilder};
30+
use log::LevelFilter;
3631

37-
// Apply platform-specific optimizations
38-
platform_optimizations::initialize();
32+
// Set up desktop logger
33+
simple_logger::SimpleLogger::new()
34+
.with_level(LevelFilter::Debug)
35+
.init()
36+
.expect("Failed to initialize logger");
3937

40-
// Configure window
41-
let window = WindowBuilder::new()
42-
.with_title("OpenSVM Dioxus")
43-
.with_inner_size(LogicalSize::new(1024.0, 768.0));
38+
// Configure window
39+
let window = WindowBuilder::new()
40+
.with_title("OpenSVM Dioxus")
41+
.with_inner_size(LogicalSize::new(1024.0, 768.0));
4442

45-
// Launch desktop app with simplified config
46-
dioxus_desktop::launch_cfg(App, Config::new().with_window(window));
47-
}
43+
// Launch desktop app with simplified config
44+
dioxus_desktop::launch_cfg(App, Config::new().with_window(window));
45+
}
4846

49-
#[cfg(feature = "android")]
50-
fn main() {
51-
// Initialize logger for Android
52-
android_logger::init_once(
53-
android_logger::Config::default()
54-
.with_min_level(log::Level::Debug)
55-
.with_tag("opensvm-dioxus"),
56-
);
47+
#[cfg(feature = "android")]
48+
{
49+
// Initialize logger for Android
50+
android_logger::init_once(
51+
android_logger::Config::default()
52+
.with_min_level(log::Level::Debug)
53+
.with_tag("opensvm-dioxus"),
54+
);
5755

58-
// Apply platform-specific optimizations
59-
platform_optimizations::initialize();
56+
// Launch Android app
57+
dioxus_mobile::launch(App);
58+
}
6059

61-
// Launch Android app
62-
dioxus_mobile::launch(App);
60+
#[cfg(not(any(feature = "web", feature = "desktop", feature = "android")))]
61+
{
62+
eprintln!("No platform feature enabled. Please build with --features web, --features desktop, or --features android");
63+
std::process::exit(1);
64+
}
6365
}

opensvm-dioxus/src/routes/account.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn AccountPage(cx: Scope<AccountPageProps>) -> Element {
4545
}
4646
}
4747

48-
#[cfg(not(feature = "web"))]
48+
#[cfg(feature = "desktop")]
4949
{
5050
let client = SolanaApiClient::new();
5151

opensvm-dioxus/src/routes/explorer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn ExplorerPage(cx: Scope) -> Element {
3535
}
3636
}
3737

38-
#[cfg(not(feature = "web"))]
38+
#[cfg(feature = "desktop")]
3939
{
4040
let client = SolanaApiClient::new();
4141
match client.get_network_stats().await {

0 commit comments

Comments
 (0)