Skip to content

Conversation

@hotwatermorning
Copy link
Collaborator

PORTAUDIO_SEARCH_PATH と PORTAUDIO_ONLY_STATIC が両方指定されているときは、 PORTAUDIO_SEARCH_PATH で指定されたパスの中から portaudio の static link ライブラリを探索してそれとリンクするようにする

@hotwatermorning hotwatermorning self-assigned this Jul 26, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @hotwatermorning, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've implemented a new feature that enhances how the rust-portaudio-sys crate links with the PortAudio library. Specifically, this change allows for static linking of PortAudio when both the PORTAUDIO_SEARCH_PATH and a new PORTAUDIO_ONLY_STATIC environment variable are set. This provides more control over the linking process, enabling users to explicitly opt for static linking from a specified path.

Highlights

  • Static Linking Control: I've added logic to build.rs that enables static linking of the PortAudio library. This is activated when both PORTAUDIO_SEARCH_PATH and the newly introduced PORTAUDIO_ONLY_STATIC environment variable are present.
  • Static Library Verification: The build script now verifies the existence of the static PortAudio library file within the PORTAUDIO_SEARCH_PATH before attempting to link it, ensuring robustness.
  • Platform-Specific Static Library Names: I've introduced PORTAUDIO_STATIC_LIB_NAME constants in platform-specific modules to correctly identify the static library file (e.g., libportaudio.a for Unix-like systems and portaudio.lib for Windows).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for finding and linking a static PortAudio library when PORTAUDIO_SEARCH_PATH and PORTAUDIO_ONLY_STATIC environment variables are set. The changes are generally good, but there's a significant cross-platform issue with path construction that needs to be addressed. I've also pointed out an opportunity to reduce code duplication for better maintainability.

Comment on lines 41 to 42
let static_lib = format!("{}/{}", search_path, platform::PORTAUDIO_STATIC_LIB_NAME);
::std::fs::metadata(&static_lib).expect(&format!("{} is not found", static_lib));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using format! to join path segments is not cross-platform compatible as it assumes a / separator, which will fail on Windows. You should use std::path::Path::join to construct paths robustly. Additionally, path.is_file() is a more direct way to check for a file's existence, and a custom panic! message can be more descriptive than expect. The leading :: on ::std::fs::metadata is also unnecessary.

Suggested change
let static_lib = format!("{}/{}", search_path, platform::PORTAUDIO_STATIC_LIB_NAME);
::std::fs::metadata(&static_lib).expect(&format!("{} is not found", static_lib));
let static_lib_path = std::path::Path::new(&search_path).join(platform::PORTAUDIO_STATIC_LIB_NAME);
if !static_lib_path.is_file() {
panic!("Static library not found: {}", static_lib_path.display());
}

use super::unix_platform;
use std::path::Path;

pub const PORTAUDIO_STATIC_LIB_NAME: &'static str = "libportaudio.a";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To avoid duplicating this constant, you can re-export PORTAUDIO_STATIC_LIB_NAME from the unix_platform module, where it's already defined with the same value.

Suggested change
pub const PORTAUDIO_STATIC_LIB_NAME: &'static str = "libportaudio.a";
pub use super::unix_platform::PORTAUDIO_STATIC_LIB_NAME;

@hotwatermorning hotwatermorning force-pushed the feat/yuasa/static-link branch from 5abf685 to 1abda0b Compare July 26, 2025 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants