Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,51 @@ set(SOURCES
add_executable(imager ${SOURCES})

# Set compiler flags
target_compile_options(imager PRIVATE -O2 -Wall)
if(MSVC)
target_compile_options(imager PRIVATE /W4 /D_CRT_SECURE_NO_WARNINGS)
# /O2 is incompatible with /RTC1 (default in Debug). CMake handles /O2 in Release by default.
else()
target_compile_options(imager PRIVATE -O2 -Wall)
endif()

# Fetch wxWidgets for Native GUI
include(FetchContent)
FetchContent_Declare(
wxWidgets
URL https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.4/wxWidgets-3.2.4.tar.bz2
)
# wxWidgets build can be slow, we only need core and base
set(wxBUILD_SHARED OFF CACHE BOOL "" FORCE)
set(wxBUILD_SAMPLES OFF CACHE BOOL "" FORCE)
set(wxBUILD_TESTS OFF CACHE BOOL "" FORCE)
set(wxBUILD_DEMOS OFF CACHE BOOL "" FORCE)
set(wxBUILD_INSTALL OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(wxWidgets)

# GUI Source files (Transitioned to C++)
set(GUI_SOURCES
src/gui_main.cpp
src/core/progress.c
src/utils/utils.c
src/utils/drive_list.c
src/core/iso_operations.c
)

# Create GUI executable
add_executable(imager-gui ${GUI_SOURCES})
target_include_directories(imager-gui PRIVATE include)

# Link wxWidgets
target_link_libraries(imager-gui PRIVATE wx::core wx::base)

if(MSVC)
target_compile_options(imager-gui PRIVATE /W4 /D_CRT_SECURE_NO_WARNINGS)
# Win32 subsystem for GUI (no console window)
set_target_properties(imager-gui PROPERTIES WIN32_EXECUTABLE TRUE)
else()
target_compile_options(imager-gui PRIVATE -O2 -Wall)
target_link_libraries(imager-gui pthread m dl)
endif()

# Install target
install(TARGETS imager DESTINATION bin)
install(TARGETS imager imager-gui DESTINATION bin)
87 changes: 44 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AvdanOS Imager

This is a Balena Etcher alternative written in C.
This is a Balena Etcher alternative written in C and C++.

## To-Do List:

Expand All @@ -14,35 +14,49 @@ Legend:

`✔️` Core ISO Imaging Engine (CLI)

`` GUI Interface
`🚧` GUI Interface (Initial Implementation)

`` Cross-Platform GUI Framework
`🚧` Cross-Platform GUI Framework (wxWidgets)

## Current Status

The project currently has a **working CLI implementation** with:
The project now supports both a **working CLI** and a **native C++ GUI**:

### CLI Features:
- ✅ ISO to USB writing
- ✅ Progress tracking
- ✅ Write verification
- ✅ Cross-platform support (Linux/macOS, no Windows yet)
- ✅ Write verification (Bit-for-bit)
- ✅ Cross-platform support (Linux, macOS, and Windows)

### GUI Features (Initial Implementation):
- ✅ **Native Windows Vibe**: Uses wxWidgets for a Rufus-like aesthetic.
- ✅ **Automated Drive Selection**: Lists friendly drive names and capacities.
- ✅ **Write Verification**: Integrated bit-for-bit verification after flashing.
- ✅ **Safety Filtering**: Filters out internal drives by default to prevent data loss.
- ✅ **High-Capacity Support**: Correctly handles drives larger than 500GB.
- ✅ **Multi-threaded**: UI remains responsive during flashing and verification.

The **GUI is planned** but not yet implemented.
> [!NOTE]
> The current GUI is an initial functional implementation. The final design and layout are subject to further refinement.

## Project Structure

```
├── include/imager/
│ ├── progress.h
│ ├── utils.h
│ ├── drive_list.h
│ ├── iso_operations.h
│ └── imager.h
├── src/
│ ├── core/
│ │ ├── progress.c
│ │ └── iso_operations.c
│ ├── utils/
│ │ └── utils.c
│ └── main.c
│ │ ├── utils.c
│ │ └── drive_list.c
│ ├── main.c (CLI Entry)
│ └── gui_main.cpp (GUI Entry)
├── docs/
│ ├── BUILD.md
│ └── USAGE.md
Expand All @@ -54,54 +68,41 @@ The **GUI is planned** but not yet implemented.
## Getting Started

### Prerequisites
- GCC compiler (or compatible C compiler)
- Make (for Makefile builds)
- CMake 3.10+ (for CMake builds)
- **GCC compiler** (MinGW-w64 for Windows) or **MSVC** (Visual Studio).
- **CMake 3.10+**.
- **wxWidgets 3.2+** (Automatically downloaded via CMake).

### Build
### Build (CMake - Recommended)
```bash
make
mkdir build && cd build
cmake ..
cmake --build .
```
This will generate two executables:
- `imager`: The command-line version.
- `imager-gui`: The native graphical version.

### Usage (GUI)
Simply run `imager-gui` as Administrator/Root, select your ISO, and choose your target USB drive from the dropdown.

### Usage (CLI)
```bash
# Linux/macOS
sudo ./imager <iso_file> <usb_device>
```

Example:
```bash
sudo ./imager ubuntu-22.04.iso /dev/sdX
# Windows (Run as Administrator)
.\imager.exe <iso_file> \\.\PhysicalDriveX
```

## Documentation

- **[BUILD.md](docs/BUILD.md)** - Detailed build instructions
- **[USAGE.md](docs/USAGE.md)** - Complete usage guide and troubleshooting

## Safety
- **You must run as root/admin to access raw devices.**
- **All data on the target device will be destroyed!**
- Double-check your device path before proceeding
- The program will prompt for confirmation before writing

## Build Systems
- Double-check your device selection before clicking START.
- The app filters out internal drives by default for safety.

### Makefile (Recommended)
```bash
make
make clean
```

### CMake
```bash
mkdir build && cd build
cmake ..
make
```

## Contributing

Please see the [contributing guidelines](CONTRIBUTING.md) for more info.
## Documentation
- **[BUILD.md](docs/BUILD.md)** - Detailed build instructions
- **[USAGE.md](docs/USAGE.md)** - Complete usage guide and troubleshooting

## License
GPLv3
Expand Down
73 changes: 19 additions & 54 deletions docs/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,84 +2,49 @@

## Overview

This document covers building the AvdanOS Imager project. Currently, only the CLI version is implemented.
This project supports both a CLI and a GUI version across Linux, macOS, and Windows.

## Prerequisites

- GCC compiler (or compatible C compiler)
- Make (for Makefile builds)
- CMake 3.10+ (for CMake builds)
- **GCC compiler** (MinGW-w64 for Windows) or **MSVC** (Visual Studio).
- **CMake 3.10+**.
- **wxWidgets 3.2+** (automatically downloaded via CMake for the GUI version).

## Build Methods

### Using Makefile (Recommended)
### Using CMake (Recommended for All Platforms)

```bash
make
```

This will create the `imager` executable in the project root.

### Using CMake

```bash
```powershell
mkdir build
cd build
cmake ..
make
cmake --build .
```

### Manual Compilation

```bash
gcc -O2 -Wall -I./include -o imager \
src/main.c \
src/core/progress.c \
src/utils/utils.c \
src/core/iso_operations.c
```
This will create:
- `imager`: The command-line version.
- `imager-gui`: The graphical user interface version.

## Cleaning
### Using Makefile (Linux/macOS CLI Only)

```bash
make clean
```

Or for CMake builds:

```bash
cd build
make clean
```

## Installation

After building, you can install the binary:

```bash
sudo cp imager /usr/local/bin/
make
```

## Future GUI Build
## Platform-Specific Notes

When the GUI is implemented, additional dependencies may be required:
### Windows
If using Visual Studio, you can open the project folder directly or use the CMake GUI to generate a `.sln` file.

- GTK+ (for Linux GUI)
- Cocoa (for macOS GUI)
- Windows API (for Windows GUI)
- Or some cross-platform framework idk yet
### Linux
Ensure you have the development headers for your graphics drivers (Mesa) and X11/Wayland if building the GUI.

## Development

For development, you can use:

```bash
# Debug build
make CFLAGS="-O0 -g -Wall -I./include"

# Or with CMake
# Debug build (with CMake)
mkdir build-debug
cd build-debug
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
cmake --build .
```
Loading