fix android
This commit is contained in:
@@ -1,5 +1,19 @@
|
|||||||
import { describe, expect, test } from "bun:test";
|
import { describe, expect, test } from "bun:test";
|
||||||
import { createAgentTlsPinsLdflag } from "./build-process";
|
import { createAgentTlsPinsLdflag, createBaseGoLdflags } from "./build-process";
|
||||||
|
|
||||||
|
describe("agent base linker flags", () => {
|
||||||
|
test("allows Pion's Android interface dependency to link on current Go", () => {
|
||||||
|
expect(createBaseGoLdflags("android", true)).toBe(
|
||||||
|
"-s -w -buildid= -checklinkname=0",
|
||||||
|
);
|
||||||
|
expect(createBaseGoLdflags("android", false)).toBe("-checklinkname=0");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("does not relax linkname checks for other targets", () => {
|
||||||
|
expect(createBaseGoLdflags("linux", true)).toBe("-s -w -buildid=");
|
||||||
|
expect(createBaseGoLdflags("windows", false)).toBe("");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("agent build TLS pin embedding", () => {
|
describe("agent build TLS pin embedding", () => {
|
||||||
test("creates the linker flag consumed by the Go agent config", () => {
|
test("creates the linker flag consumed by the Go agent config", () => {
|
||||||
|
|||||||
@@ -31,6 +31,15 @@ export function createAgentTlsPinsLdflag(pins: string[]): string {
|
|||||||
return `-X overlord-client/cmd/agent/config.DefaultTLSSPKIPins=${pins.join(",")}`;
|
return `-X overlord-client/cmd/agent/config.DefaultTLSSPKIPins=${pins.join(",")}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createBaseGoLdflags(targetOs: string, stripDebug: boolean): string {
|
||||||
|
const flags: string[] = [];
|
||||||
|
if (stripDebug) flags.push("-s", "-w", "-buildid=");
|
||||||
|
|
||||||
|
if (targetOs === "android") flags.push("-checklinkname=0");
|
||||||
|
|
||||||
|
return flags.join(" ");
|
||||||
|
}
|
||||||
|
|
||||||
function isClientModuleDir(dir: string): boolean {
|
function isClientModuleDir(dir: string): boolean {
|
||||||
return (
|
return (
|
||||||
fs.existsSync(path.join(dir, "go.mod")) &&
|
fs.existsSync(path.join(dir, "go.mod")) &&
|
||||||
@@ -1213,7 +1222,7 @@ func runBoundFiles() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let ldflags = config.stripDebug !== false ? "-s -w -buildid=" : "";
|
let ldflags = createBaseGoLdflags(effectiveOs, config.stripDebug !== false);
|
||||||
|
|
||||||
if (config.serverUrl) {
|
if (config.serverUrl) {
|
||||||
const serverFlag = `-X overlord-client/cmd/agent/config.DefaultServerURL=${config.serverUrl}`;
|
const serverFlag = `-X overlord-client/cmd/agent/config.DefaultServerURL=${config.serverUrl}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user