Repository navigation
feat: Android/Termux headless support #2273
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
Changes from 3 commits
ae8e625
6f25dd2
fcfdce5
5e715f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,10 +141,20 @@ async function fixBetterSqliteBinary() { | |
| ? "npm install better-sqlite3 --build-from-source --force" | ||
| : "npm rebuild better-sqlite3"; | ||
|
|
||
| const env = { ...process.env }; | ||
| if (isAndroid) { | ||
| env.GYP_DEFINES = "android_ndk_path=''"; | ||
| } | ||
|
|
||
| // app/ may not exist when running from source (before `npm run build`) | ||
| const appDir = join(ROOT, "app"); | ||
| const rebuildCwd = existsSync(appDir) ? appDir : ROOT; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ternary operator const rebuildCwd = appDir; |
||
|
|
||
| execSync(rebuildCmd, { | ||
| cwd: join(ROOT, "app"), | ||
| cwd: rebuildCwd, | ||
| stdio: "inherit", | ||
| timeout: 300_000, // 5 minutes for source builds | ||
| timeout: isAndroid ? 600_000 : 300_000, // ARM compilation is slower | ||
| env, | ||
| }); | ||
|
|
||
| process.dlopen({ exports: {} }, appBinary); | ||
|
|
@@ -153,7 +163,8 @@ async function fixBetterSqliteBinary() { | |
| } catch (err) { | ||
| const isTimeout = err.killed || err.signal === "SIGTERM"; | ||
| if (isTimeout) { | ||
| console.warn(" ⚠️ npm rebuild timed out after 300s."); | ||
| const secs = process.platform === "android" ? 600 : 300; | ||
| console.warn(` ⚠️ npm rebuild timed out after ${secs}s.`); | ||
| } else { | ||
| console.warn(` ⚠️ npm rebuild failed: ${err.message}`); | ||
| } | ||
|
|
@@ -189,6 +200,11 @@ async function fixBetterSqliteBinary() { | |
| * Fixes: https://github.com/diegosouzapw/OmniRoute/issues/1634 | ||
| */ | ||
| async function fixWreqJsBinary() { | ||
| if (process.platform === "android") { | ||
| console.log(" [postinstall] wreq-js: skipped on android (unsupported platform)"); | ||
| return; | ||
| } | ||
|
|
||
| const appWreqDir = join(ROOT, "app", "node_modules", "wreq-js", "rust"); | ||
| const rootWreqDir = join(ROOT, "node_modules", "wreq-js", "rust"); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The platform log message hardcodes
arm64. While this is the most common architecture for Android/Termux, it is better to useprocess.archto accurately reflect the actual environment (e.g., when running on x86_64 emulators or other ARM variants).