Skip to content

Conversation

@choyy
Copy link
Contributor

@choyy choyy commented Dec 10, 2025

fix #6167, and maybe #8499

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @choyy, 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!

This pull request addresses a persistent build failure in FFmpeg when compiled within a MinGW64 environment, specifically targeting issues arising from config.h files encoded in GBK or similar Chinese character sets. The solution involves integrating the uchardet tool into the MSYS2 build environment and then using it to automatically detect and convert problematic config.h files to UTF-8 with a Byte Order Mark (BOM) before the FFmpeg autoconf installation step. This ensures consistent encoding and prevents build interruptions, ultimately fixing issues #6167 and potentially #8499.

Highlights

  • Encoding Fix for FFmpeg Build: Implemented a mechanism to detect and convert GBK-encoded config.h files to UTF-8 with a Byte Order Mark (BOM) during the FFmpeg build process on MinGW64, resolving build failures.
  • uchardet Integration: Integrated the uchardet tool into the MSYS2 package configuration, making it available for character encoding detection in the build environment.
  • Dependency Management: Added uchardet as a required configuration for FFmpeg builds under MinGW64 to facilitate the encoding conversion.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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
Contributor

@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 addresses a build failure for ffmpeg on systems with GBK encoding by introducing uchardet to detect and convert a configuration file to UTF-8. The changes are logical and well-targeted. I've provided a couple of suggestions for improvement: one to ensure the fix is applied consistently across all Windows build paths, and another to improve the robustness of the shell script by quoting a file path variable. Overall, this is a good fix for the reported issue.

Comment on lines +276 to +281
io.replace("configure", "cp_if_changed $TMPH config.h", [[
config_encodings=$(uchardet $TMPH)
case "$config_encodings" in GB18030|GBK|GB2312)
{ printf '\xEF\xBB\xBF'; iconv -f "$config_encodings" -t UTF-8 -c $TMPH; } > config.h;;
*) cp_if_changed $TMPH config.h;;
esac]], {plain = true})
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This is a great fix for the encoding issue. However, this io.replace call is inside an if path.cygwin then block. There is another code path for Windows builds in the else block (starting on line 283) which also invokes the ./configure script. This fix should also be applied there to ensure consistent behavior for all Windows builds. You could move this block of code to before the if path.cygwin then check (e.g., after line 274) to apply it to both paths.

Comment on lines +277 to +280
config_encodings=$(uchardet $TMPH)
case "$config_encodings" in GB18030|GBK|GB2312)
{ printf '\xEF\xBB\xBF'; iconv -f "$config_encodings" -t UTF-8 -c $TMPH; } > config.h;;
*) cp_if_changed $TMPH config.h;;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For robustness, it's a good practice to quote the $TMPH variable in shell scripts to handle potential spaces or special characters in the file path.

                    config_encodings=$(uchardet "$TMPH")
                    case "$config_encodings" in GB18030|GBK|GB2312)
                        { printf '\xEF\xBB\xBF'; iconv -f "$config_encodings" -t UTF-8 -c "$TMPH"; } > config.h;; 
                    *) cp_if_changed "$TMPH" config.h;;

@waruqi waruqi merged commit a32ec8a into xmake-io:dev Dec 10, 2025
61 checks passed
@choyy choyy deleted the ffmpeg branch December 11, 2025 00:48
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.

安装opencv库时依赖的FFmpeg安装失败

2 participants