Skip to content

Commit bb98d08

Browse files
committed
Remove incremental linking
1 parent 58996f0 commit bb98d08

File tree

5 files changed

+5
-88
lines changed

5 files changed

+5
-88
lines changed

packages/host/src/node/cli/android.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
22
import fs from "node:fs";
33
import path from "node:path";
44

5-
import { getLatestMtime, getLibraryName, MAGIC_FILENAME } from "../path-utils";
5+
import { getLibraryName, MAGIC_FILENAME } from "../path-utils";
66
import {
77
getLinkedModuleOutputPath,
88
LinkModuleResult,
@@ -17,27 +17,13 @@ const ANDROID_ARCHITECTURES = [
1717
] as const;
1818

1919
export async function linkAndroidDir({
20-
incremental,
2120
modulePath,
2221
naming,
2322
platform,
2423
}: LinkModuleOptions): Promise<LinkModuleResult> {
2524
const libraryName = getLibraryName(modulePath, naming);
2625
const outputPath = getLinkedModuleOutputPath(platform, modulePath, naming);
2726

28-
if (incremental && fs.existsSync(outputPath)) {
29-
const moduleModified = getLatestMtime(modulePath);
30-
const outputModified = getLatestMtime(outputPath);
31-
if (moduleModified < outputModified) {
32-
return {
33-
originalPath: modulePath,
34-
libraryName,
35-
outputPath,
36-
skipped: true,
37-
};
38-
}
39-
}
40-
4127
await fs.promises.rm(outputPath, { recursive: true, force: true });
4228
await fs.promises.cp(modulePath, outputPath, { recursive: true });
4329
for (const arch of ANDROID_ARCHITECTURES) {

packages/host/src/node/cli/apple.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ import * as xcode from "@bacons/xcode";
77
import * as xcodeJson from "@bacons/xcode/json";
88
import * as zod from "zod";
99

10-
import { assertFixable, chalk, spawn } from "@react-native-node-api/cli-utils";
10+
import { chalk, spawn } from "@react-native-node-api/cli-utils";
1111

12-
import { getLatestMtime, getLibraryName } from "../path-utils.js";
12+
import { getLibraryName } from "../path-utils.js";
1313
import {
14-
getLinkedModuleOutputPath,
1514
LinkModuleOptions,
1615
LinkModuleResult,
1716
ModuleLinker,
1817
} from "./link-modules.js";
19-
import { findXcodeProject, getBuildDirPath } from "./xcode-helpers.js";
18+
import { findXcodeProject } from "./xcode-helpers.js";
2019

2120
const PACKAGE_ROOT = path.resolve(__dirname, "..", "..", "..");
2221
const CLI_PATH = path.resolve(PACKAGE_ROOT, "bin", "react-native-node-api.mjs");
@@ -461,21 +460,13 @@ export function determineFrameworkSlice(): {
461460
export async function linkXcframework({
462461
platform,
463462
modulePath,
464-
incremental,
465463
naming,
466464
outputPath: outputParentPath,
467465
signingIdentity,
468466
}: LinkModuleOptions & {
469467
outputPath: string;
470468
signingIdentity?: string;
471469
}): Promise<LinkModuleResult> {
472-
assertFixable(
473-
!incremental,
474-
"Incremental linking is not supported for Apple frameworks",
475-
{
476-
instructions: "Run the command with the --force flag",
477-
},
478-
);
479470
// Copy the xcframework to the output directory and rename the framework and binary
480471
const newLibraryName = getLibraryName(modulePath, naming);
481472
const frameworkOutputPath = path.join(

packages/host/src/node/cli/link-modules.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export type ModuleLinker = (
2323

2424
export type LinkModulesOptions = {
2525
platform: PlatformName;
26-
incremental: boolean;
2726
naming: NamingStrategy;
2827
fromPath: string;
2928
linker: ModuleLinker;
@@ -61,7 +60,6 @@ type ModuleOutput = ModuleOutputBase &
6160

6261
export async function linkModules({
6362
fromPath,
64-
incremental,
6563
naming,
6664
platform,
6765
linker,
@@ -96,7 +94,6 @@ export async function linkModules({
9694
try {
9795
return await linker({
9896
modulePath: originalPath,
99-
incremental,
10097
naming,
10198
platform,
10299
});

packages/host/src/node/cli/program.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ function getPlatformDisplayName(platform: PlatformName) {
6262
program
6363
.command("link")
6464
.argument("[path]", "Some path inside the app package", process.cwd())
65-
.option(
66-
"--force",
67-
"Don't check timestamps of input files to skip unnecessary rebuilds",
68-
false,
69-
)
7065
.option(
7166
"--prune",
7267
"Delete vendored modules that are no longer auto-linked",
@@ -78,10 +73,7 @@ program
7873
.addOption(pathSuffixOption)
7974
.action(
8075
wrapAction(
81-
async (
82-
pathArg,
83-
{ force, prune, pathSuffix, android, apple, packageName },
84-
) => {
76+
async (pathArg, { prune, pathSuffix, android, apple, packageName }) => {
8577
console.log("Auto-linking Node-API modules from", chalk.dim(pathArg));
8678
const platforms: PlatformName[] = [];
8779
if (android) {
@@ -107,7 +99,6 @@ program
10799
await linkModules({
108100
platform,
109101
fromPath: path.resolve(pathArg),
110-
incremental: !force,
111102
naming: { packageName, pathSuffix },
112103
linker: await createLinker(platform, path.resolve(pathArg)),
113104
}),

packages/host/src/node/cli/xcode-helpers.ts

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import cp from "node:child_process";
66
// Using xmldom here because this is what @expo/plist uses internally and we might as well re-use it here.
77
// Types come from packages/host/types/xmldom.d.ts (path mapping in tsconfig.node.json) to avoid pulling in lib "dom".
88
import { DOMParser } from "@xmldom/xmldom";
9-
import xcode from "@bacons/xcode";
10-
import * as zod from "zod";
119

1210
export type XcodeWorkspace = {
1311
version: string;
@@ -90,49 +88,3 @@ export async function findXcodeProject(fromPath: string) {
9088
throw new Error(`Unexpected scheme: ${scheme}`);
9189
}
9290
}
93-
94-
const BuildSettingsSchema = zod.array(
95-
zod.object({
96-
target: zod.string(),
97-
buildSettings: zod.partialRecord(zod.string(), zod.string()),
98-
}),
99-
);
100-
101-
export function getBuildSettings(
102-
xcodeProjectPath: string,
103-
mainTarget: xcode.PBXNativeTarget,
104-
) {
105-
const result = cp.spawnSync(
106-
"xcodebuild",
107-
[
108-
"-showBuildSettings",
109-
"-project",
110-
xcodeProjectPath,
111-
"-target",
112-
mainTarget.getDisplayName(),
113-
"-json",
114-
],
115-
{
116-
cwd: xcodeProjectPath,
117-
encoding: "utf-8",
118-
},
119-
);
120-
assert.equal(
121-
result.status,
122-
0,
123-
`Failed to run xcodebuild -showBuildSettings: ${result.stderr}`,
124-
);
125-
return BuildSettingsSchema.parse(JSON.parse(result.stdout));
126-
}
127-
128-
export function getBuildDirPath(
129-
xcodeProjectPath: string,
130-
mainTarget: xcode.PBXNativeTarget,
131-
) {
132-
const buildSettings = getBuildSettings(xcodeProjectPath, mainTarget);
133-
assert(buildSettings.length === 1, "Expected exactly one build setting");
134-
const [targetBuildSettings] = buildSettings;
135-
const { BUILD_DIR: buildDirPath } = targetBuildSettings.buildSettings;
136-
assert(buildDirPath, "Expected a build directory");
137-
return buildDirPath;
138-
}

0 commit comments

Comments
 (0)