Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rcbridge: Set cache dir via XDG_CACHE_HOME #12

Merged
merged 1 commit into from
Jun 19, 2023
Merged

rcbridge: Set cache dir via XDG_CACHE_HOME #12

merged 1 commit into from
Jun 19, 2023

Conversation

chenxiaolong
Copy link
Owner

Due to how golang calls each packages' init() functions, it's impossible to have a shared library function that runs before any of the init()s. Instead, we'll set the XDG_CACHE_HOME environment variable. This has its own problems because calling setenv() from the Kotlin side only affects libc's global environ variable, which golang does not use (it maintains its own copy of envp). This commit works around that by importing a new envhack package that explicitly copies libc's environ to golang via CGO.

Fixes: #11

@chenxiaolong chenxiaolong self-assigned this Jun 19, 2023
Due to how golang calls each packages' init() functions, it's impossible
to have a shared library function that runs before any of the init()s.
Instead, we'll set the XDG_CACHE_HOME environment variable. This has its
own problems because calling setenv() from the Kotlin side only affects
libc's global environ variable, which golang does not use (it maintains
its own copy of envp). This commit works around that by importing a new
envhack package that explicitly copies libc's environ to golang via CGO.

Fixes: #11

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
@chenxiaolong chenxiaolong merged commit dd82839 into master Jun 19, 2023
@chenxiaolong chenxiaolong deleted the envhack branch June 19, 2023 22:18
chenxiaolong added a commit that referenced this pull request Jun 19, 2023
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
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.

Path config options should get Android-specific defaults
1 participant