Skip to content

Commit 8f79a56

Browse files
committed
add changes
1 parent d65090e commit 8f79a56

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

packages/ferric/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1-
# `ferric`
1+
# `ferric` (ESM Module)
22

33
A wrapper around Cargo making it easier to produce prebuilt binaries targeting iOS and Android matching the [the prebuilt binary specification](https://github.com/callstackincubator/react-native-node-api/blob/main/docs/PREBUILDS.md) as well as [napi.rs](https://napi.rs/) to generate bindings from annotated Rust code.
4+
5+
## Install the project
6+
7+
`npm install --save-dev ferric-cli`
8+
9+
## Add scripts
10+
11+
```json
12+
"scripts": {
13+
"build": "ferric build --cwd folder_path",
14+
"build:release": "npm run build --configuration release",
15+
},
16+
```

packages/ferric/src/build.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ const outputPathOption = new Option(
9797
"--output <path>",
9898
"Writing outputs to this directory"
9999
).default(process.cwd());
100+
const cwdPathOption = new Option(
101+
"--cwd <path>",
102+
"Specify project path"
103+
).default(process.cwd());
100104
const configurationOption = new Option(
101105
"--configuration <configuration>",
102106
"Build configuration"
@@ -111,6 +115,7 @@ export const buildCommand = new Command("build")
111115
.addOption(androidTarget)
112116
.addOption(ndkVersionOption)
113117
.addOption(outputPathOption)
118+
.addOption(cwdPathOption)
114119
.addOption(configurationOption)
115120
.addOption(xcframeworkExtensionOption)
116121
.action(
@@ -120,6 +125,7 @@ export const buildCommand = new Command("build")
120125
android,
121126
ndkVersion,
122127
output: outputPath,
128+
cwd,
123129
configuration,
124130
xcframeworkExtension,
125131
}) => {
@@ -175,7 +181,7 @@ export const buildCommand = new Command("build")
175181
Promise.all(
176182
appleTargets.map(
177183
async (target) =>
178-
[target, await build({ configuration, target })] as const
184+
[target, await build({ configuration, target, sourcePath: cwd })] as const
179185
)
180186
),
181187
Promise.all(
@@ -186,6 +192,7 @@ export const buildCommand = new Command("build")
186192
await build({
187193
configuration,
188194
target,
195+
sourcePath: cwd,
189196
ndkVersion,
190197
androidApiLevel: ANDROID_API_LEVEL,
191198
}),
@@ -274,7 +281,7 @@ export const buildCommand = new Command("build")
274281
await oraPromise(
275282
generateTypeScriptDeclarations({
276283
outputFilename: declarationsFilename,
277-
createPath: process.cwd(),
284+
createPath: cwd,
278285
outputPath,
279286
}),
280287
{

packages/ferric/src/cargo.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export function ensureCargo() {
6161

6262
type BuildOptions = {
6363
configuration: "debug" | "release";
64+
sourcePath: string;
6465
} & (
6566
| {
6667
target: AndroidTargetName;
@@ -75,8 +76,9 @@ type BuildOptions = {
7576
);
7677

7778
export async function build(options: BuildOptions) {
78-
const { target, configuration } = options;
79-
const args = ["build", "--target", target]
79+
const { target, configuration, sourcePath } = options;
80+
const manifestBuildPath = `${sourcePath}/Cargo.toml`;
81+
const args = ["build", "--target", target, manifestBuildPath]
8082
if (configuration.toLowerCase() === 'release') {
8183
args.push('--release')
8284
}

0 commit comments

Comments
 (0)