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

Remove torrent dependencies at build time for mobile #5146

Open
Samyoul opened this issue May 10, 2024 · 4 comments · May be fixed by #5257
Open

Remove torrent dependencies at build time for mobile #5146

Samyoul opened this issue May 10, 2024 · 4 comments · May be fixed by #5257

Comments

@Samyoul
Copy link
Member

Samyoul commented May 10, 2024

Tor takes up a massive amount of space even once compiled, mobile doesn't use it, mobile shouldn't have it in its build, it will help in the app stores. Investigate and fix.

@Samyoul
Copy link
Member Author

Samyoul commented May 16, 2024

The only instance of the torrent packages import is in a single file. This makes targeting the package for selective compiling much eaiser.

"github.com/anacrolix/torrent"
"github.com/anacrolix/torrent/bencode"
"github.com/anacrolix/torrent/metainfo"

@Samyoul
Copy link
Member Author

Samyoul commented May 16, 2024

A workable solution for this issue is to have different files for different build environments.

File Structure:

manager_desktop.go — This file will contain imports and code used only in desktop builds. Therefore only importing torrent related code.
manager_mobile.go — This file will be for mobile builds and will not include the torrent related packages.

Build based on GOOS

manager_desktop.go

// +build windows linux darwin

package communities

func WithTorrent(manager *Manager) {
    // Implementation specific to Desktop
}

manager_mobile.go

// +build android ios

package communities

// No use of the WithTorrent() func.

@siddarthkay
Copy link
Contributor

here is an example of a PR I had made a while ago to make sure we build a certain part of this library only for android x86_64 architecture which used build flags.
status-im/tcp-shaker#1

@Samyoul
Copy link
Member Author

Samyoul commented May 29, 2024

Ok, I'm starting work on this now.

@Samyoul Samyoul linked a pull request May 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

3 participants