diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 0000000..e7fdef7 --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +8.4.2 diff --git a/.gitignore b/.gitignore index ad67955..40fbfa1 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,7 @@ target # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +# Bazel build artifacts +bazel-* +.bazel-cache diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..b97d58b --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,14 @@ +"""Rusty MP3 Player - Bazel Module""" + +module( + name = "rusty-mp3", + version = "0.1.0", +) + +bazel_dep(name = "rules_rust", version = "0.48.0") + +rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") +rust.toolchain(edition = "2021") +use_repo(rust, "rust_toolchains") + +register_toolchains("@rust_toolchains//:all") diff --git a/README.md b/README.md index a1308fc..4a61008 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,38 @@ # rusty-mp3 Simple mp3 player written in Rust for learning purposes + +## Project Structure + +- `src/` - Source code for the MP3 player +- `tests/` - Integration and unit tests +- `docs/` - Project documentation in reStructuredText format + +## Building + +This project uses Bazel as its build system. To build the project: + +```bash +bazel build //src:rusty-mp3 +``` + +## Running + +To run the MP3 player: + +```bash +bazel run //src:rusty-mp3 +``` + +## Testing + +To run the tests: + +```bash +bazel test //tests:all +``` + +## Documentation + +See the `docs/` directory for detailed documentation: +- `docs/index.rst` - Main documentation +- `docs/architecture.rst` - Architecture overview diff --git a/docs/architecture.rst b/docs/architecture.rst new file mode 100644 index 0000000..fa94270 --- /dev/null +++ b/docs/architecture.rst @@ -0,0 +1,65 @@ +Architecture +============ + +This document describes the architecture of the Rusty MP3 player. + +Components +---------- + +The MP3 player is designed with the following components: + +Main Application +~~~~~~~~~~~~~~~~ + +The main application entry point handles: + +* Command-line argument parsing +* Application initialization +* Coordinating between different components + +MP3 Parser (Future) +~~~~~~~~~~~~~~~~~~~ + +The MP3 parser component will be responsible for: + +* Reading MP3 file headers +* Parsing MP3 frames +* Extracting audio data and metadata + +Audio Player (Future) +~~~~~~~~~~~~~~~~~~~~~ + +The audio player component will handle: + +* Audio output device management +* Audio buffer management +* Playback control (play, pause, stop, seek) + +Design Principles +----------------- + +The project follows these design principles: + +* **Modularity**: Components are separated into distinct modules +* **Testability**: Code is written to be easily testable +* **Learning-focused**: Code is documented and easy to understand +* **Bazel build**: Modern build system with clear dependencies + +Technology Stack +---------------- + +* **Language**: Rust +* **Build System**: Bazel (using Bazelmod/bzlmod) +* **Audio Libraries**: TBD (possibly rodio or cpal) +* **Testing**: Rust's built-in test framework + +Build System +------------ + +The project uses Bazel with Bazelmod (MODULE.bazel) for build configuration. +This provides: + +* Reproducible builds +* Clear dependency management +* Fast incremental builds +* Cross-platform support diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..bd086f6 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,69 @@ +Rusty MP3 Player Documentation +=============================== + +Welcome to the Rusty MP3 Player documentation! + +Overview +-------- + +Rusty MP3 is a simple MP3 player written in Rust for learning purposes. +This project aims to provide a basic understanding of: + +* Audio file handling +* MP3 format parsing +* Audio playback in Rust +* Building Rust projects with Bazel + +Getting Started +--------------- + +Building the Project +~~~~~~~~~~~~~~~~~~~~ + +This project uses Bazel as its build system. To build the project:: + + bazel build //src:rusty-mp3 + +Running the Player +~~~~~~~~~~~~~~~~~~ + +To run the MP3 player:: + + bazel run //src:rusty-mp3 + +Testing +~~~~~~~ + +To run the tests:: + + bazel test //tests:all + +Project Structure +----------------- + +The project is organized as follows: + +* ``src/`` - Source code for the MP3 player +* ``tests/`` - Integration and unit tests +* ``docs/`` - Project documentation in reStructuredText format + +Future Enhancements +------------------- + +Planned features include: + +* MP3 file parsing +* Audio playback support +* Playlist management +* Command-line interface +* Configuration options + +Contributing +------------ + +This is a learning project. Feel free to experiment and extend it! + +License +------- + +This project is for educational purposes. diff --git a/src/BUILD.bazel b/src/BUILD.bazel new file mode 100644 index 0000000..e1ad5b8 --- /dev/null +++ b/src/BUILD.bazel @@ -0,0 +1,8 @@ +load("@rules_rust//rust:defs.bzl", "rust_binary") + +rust_binary( + name = "rusty-mp3", + srcs = ["main.rs"], + edition = "2021", + visibility = ["//visibility:public"], +) diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..106eea3 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Rusty MP3 Player"); + println!("A simple MP3 player written in Rust for learning purposes"); +} diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel new file mode 100644 index 0000000..da55019 --- /dev/null +++ b/tests/BUILD.bazel @@ -0,0 +1,7 @@ +load("@rules_rust//rust:defs.bzl", "rust_test") + +rust_test( + name = "integration_test", + srcs = ["integration_test.rs"], + edition = "2021", +) diff --git a/tests/integration_test.rs b/tests/integration_test.rs new file mode 100644 index 0000000..443f443 --- /dev/null +++ b/tests/integration_test.rs @@ -0,0 +1,4 @@ +#[test] +fn test_basic() { + assert_eq!(2 + 2, 4); +}