Skip to content

Commit

Permalink
build(create-farm): add multiple platforms (#1689)
Browse files Browse the repository at this point in the history
* build(create): add multiple platforms

* chore(create): update meta data

* chore(create): update napi meta data

* chore(create): bump version

* ci(build): use pnpm cache

* ci(build): add target `armv7-linux-androideabi`

* ci(build): remove zig

* ci(build): only build `create-farm`

* ci(build): update setup node action to v4

* ci(build): add debug action

* ci(build): try use zig abi

* ci(build): remove zig for android

* ci(build): fix android abi name

* ci(build): add build script

* ci(build): fix file list

* ci(build): add target for android

* ci(build): support `86_64-apple-darwin`

* ci(build): add target

* chore: update download action to v4

* ci(build): add 2 arch for` create-farm`

* ci(build): fix target

* ci(build): fix gcc link

* ci(build): fix gcc link library

* build(cargo): fix linker

* ci(build): setup zig

* ci(build): fix abi name

* ci(check): check create farm artifacts

* ci(release): move release artifacts

* chore(cspell): fix words

* ci(build): fix abi name

* ci(build): fix `create-farm` artifacts check

* ci(release): fix `android-arm64` abi name

---------

Co-authored-by: brightwu <1521488775@qq.com>
  • Loading branch information
fu050409 and wre232114 committed Aug 16, 2024
1 parent dbc3203 commit a785d6f
Show file tree
Hide file tree
Showing 26 changed files with 325 additions and 81 deletions.
4 changes: 4 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ rustflags = ["-C", "target-feature=+crt-static", "-Zshare-generics=y"]

[target.aarch64-pc-windows-msvc]
linker = "rust-lld"

[target.armv7-unknown-linux-gnueabi]
linker = "arm-linux-gnueabihf-gcc"
rustflags = ["-C", "target-feature=-crt-static"]
5 changes: 5 additions & 0 deletions .changeset/slow-ravens-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-farm": patch
---

Add multiple platforms for `create-farm` and update meta data
18 changes: 9 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ jobs:
- name: Install Dependencies
run: npm install -g pnpm@9.1.0 && pnpm i --frozen-lockfile

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
id: download
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}
path: ./packages/core/binding

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
id: download-plugin-sass
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-plugin-sass
path: ./rust-plugins/sass/npm/${{ matrix.settings.abi }}

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
id: download-plugin-react
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-plugin-react
path: ./rust-plugins/react/npm/${{ matrix.settings.abi }}

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
id: download-create-farm-rust
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
run: npm install -g pnpm@9.1.0 && pnpm i --frozen-lockfile
- name: Build CLI and Core
run: pnpm --filter @farmfe/cli run build
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
id: download
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}
Expand All @@ -146,7 +146,7 @@ jobs:
runs-on: ubuntu-latest
needs: call-rust-build
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
path: /tmp/artifacts
- name: Check
Expand All @@ -161,12 +161,12 @@ jobs:
runs-on: ubuntu-latest
needs: call-rust-build
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
path: /tmp/artifacts
- name: Check
run: |
for abi in linux-x64-gnu linux-x64-musl darwin-x64 win32-x64-msvc linux-arm64-musl linux-arm64-gnu darwin-arm64 win32-ia32-msvc win32-arm64-msvc
for abi in linux-x64-gnu linux-x64-musl darwin-x64 win32-x64-msvc linux-arm64-musl linux-arm64-gnu darwin-arm64 win32-ia32-msvc win32-arm64-msvc android-arm64 linux-arm-gnueabihf android-arm-eabi
do
ls /tmp/artifacts/
test -f /tmp/artifacts/${{ github.sha }}-${abi}-create-farm/create-farm.${abi}.node
Expand All @@ -183,7 +183,7 @@ jobs:
- name: plugin-sass
- name: plugin-react
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
path: /tmp/artifacts
- name: Check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: npm install -g pnpm@9.4.0 && pnpm i --frozen-lockfile
- name: Build CLI and Core
run: pnpm --filter @farmfe/cli run build
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
id: download
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
node-version: 18.x

# batch download artifacts
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
path: /tmp/artifacts
- name: Copy Farm Core Binary
Expand All @@ -43,6 +43,11 @@ jobs:
test -f ./rust-plugins/react/npm/${abi}/index.farm
test -f ./rust-plugins/sass/npm/${abi}/index.farm
done
for abi in android-arm-eabi linux-arm-gnueabihf android-arm64
do
mv /tmp/artifacts/${{ github.sha }}-${abi}-create-farm/* ./packages/create-farm/npm/${abi}
test -f ./packages/create-farm/npm/${abi}/create-farm.${abi}.node
done
- name: Install Dependencies
run: npm install -g pnpm@9.1.0 && pnpm i --frozen-lockfile
Expand Down
62 changes: 45 additions & 17 deletions .github/workflows/rust-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ jobs:
- os: windows-latest
abi: win32-x64-msvc
target: x86_64-pc-windows-msvc
- os: macos-13
abi: darwin-x64
target: x86_64-apple-darwin
- os: macos-latest
abi: darwin-arm64
target: aarch64-apple-darwin

# cross compile
# windows. Note swc plugins is not supported on ia32 and arm64
Expand Down Expand Up @@ -78,27 +81,46 @@ jobs:
abi: linux-arm64-gnu
target: aarch64-unknown-linux-gnu
zig: true
# - os: ubuntu-latest
# abi: darwin-x64
# target: x86_64-apple-darwin
# osxcross: true
# zig: true
# - os: ubuntu-latest
# abi: darwin-arm64
# target: aarch64-apple-darwin
# osxcross: true
# zig: true
# Build for Create Farm CLI only
- os: ubuntu-latest
abi: android-arm-eabi
target: armv7-linux-androideabi
build: pnpm --filter create-farm build --target armv7-linux-androideabi
cli_only: true
zig: false
- os: ubuntu-latest
abi: linux-arm-gnueabihf
target: armv7-unknown-linux-gnueabihf
build: >-
sudo apt-get update && sudo apt-get install gcc-arm-linux-gnueabihf -y &&
pnpm --filter create-farm build --target armv7-unknown-linux-gnueabihf --zig
cli_only: true
zig: true
- os: ubuntu-latest
abi: android-arm64
target: aarch64-linux-android
build: pnpm --filter create-farm build --target aarch64-linux-android
cli_only: true
zig: false
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Cache rust artifacts
uses: Swatinem/rust-cache@v2
with:
shared-key: rust-build-${{ matrix.settings.abi }}
- uses: actions/setup-node@v3
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.1.0
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'pnpm'
- name: Install Dependencies
run: npm install -g pnpm@9.1.0 && pnpm i --frozen-lockfile
run: pnpm i --frozen-lockfile

- name: Build Plugin Tools
run: pnpm --filter @farmfe/plugin-tools run build
- run: rustup target add ${{ matrix.settings.target }}
Expand Down Expand Up @@ -133,23 +155,29 @@ jobs:
if: ${{ !matrix.settings.docker && matrix.settings.build }}
run: ${{ matrix.settings.build }}
shell: bash
- name: LS Create Farm Rust
if: ${{ matrix.settings.cli_only }}
run: ls -la ./packages/create-farm/
- name: Upload Core
uses: actions/upload-artifact@v3
if: ${{ !matrix.settings.cli_only }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}
path: ./packages/core/binding/farm.${{ matrix.settings.abi }}.node
- name: Upload Create Farm Rust
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-create-farm
path: ./packages/create-farm/create-farm.${{ matrix.settings.abi }}.node
- name: Upload Plugin React
uses: actions/upload-artifact@v3
if: ${{ !matrix.settings.cli_only }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-plugin-react
path: rust-plugins/react/npm/${{ matrix.settings.abi }}/index.farm
- name: Upload Plugin Sass
uses: actions/upload-artifact@v3
if: ${{ !matrix.settings.cli_only }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-plugin-sass
path: rust-plugins/sass/npm/${{ matrix.settings.abi }}/index.farm
2 changes: 2 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
"aarch",
"addtional",
"Alexey",
"androideabi",
"antd",
"Antdv",
"apng",
"applescript",
"Architecure",
"armv",
"arraify",
"Avenir",
"Basepath",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-farm/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

/* auto-generated by NAPI-RS */

export function run(args: Array<string>, binName?: string | undefined | null, pkgManager?: string | undefined | null): void
export declare function run(args: Array<string>, binName?: string | undefined | null, pkgManager?: string | undefined | null): void
3 changes: 3 additions & 0 deletions packages/create-farm/npm/android-arm-eabi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `create-farm-android-arm-eabi`

This is the **armv7-linux-androideabi** binary for `create-farm`
26 changes: 26 additions & 0 deletions packages/create-farm/npm/android-arm-eabi/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "create-farm-android-arm-eabi",
"version": "0.0.12",
"os": [
"android"
],
"cpu": [
"arm"
],
"main": "create-farm.android-arm-eabi.node",
"files": [
"create-farm.android-arm-eabi.node"
],
"description": "Rapidly create a new farm project.",
"keywords": [
"farm",
"create-farm"
],
"author": "",
"homepage": "https://www.farmfe.org/docs/quick-start#create-a-farm-project",
"license": "ISC",
"repository": "https://github.com/farm-fe/farm/tree/main/packages/create-farm",
"bugs": {
"url": "https://github.com/farm-fe/farm/issues"
}
}
3 changes: 3 additions & 0 deletions packages/create-farm/npm/android-arm64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `create-farm-android-arm64`

This is the **aarch64-linux-android** binary for `create-farm`
26 changes: 26 additions & 0 deletions packages/create-farm/npm/android-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "create-farm-android-arm64",
"version": "0.0.12",
"os": [
"android"
],
"cpu": [
"arm64"
],
"main": "create-farm.android-arm64.node",
"files": [
"create-farm.android-arm64.node"
],
"description": "Rapidly create a new farm project.",
"keywords": [
"farm",
"create-farm"
],
"author": "",
"homepage": "https://www.farmfe.org/docs/quick-start#create-a-farm-project",
"license": "ISC",
"repository": "https://github.com/farm-fe/farm/tree/main/packages/create-farm",
"bugs": {
"url": "https://github.com/farm-fe/farm/issues"
}
}
18 changes: 13 additions & 5 deletions packages/create-farm/npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-farm-darwin-arm64",
"version": "0.0.0",
"version": "0.0.12",
"os": [
"darwin"
],
Expand All @@ -11,8 +11,16 @@
"files": [
"create-farm.darwin-arm64.node"
],
"license": "MIT",
"engines": {
"node": ">= 10"
"description": "Rapidly create a new farm project.",
"keywords": [
"farm",
"create-farm"
],
"author": "",
"homepage": "https://www.farmfe.org/docs/quick-start#create-a-farm-project",
"license": "ISC",
"repository": "https://github.com/farm-fe/farm/tree/main/packages/create-farm",
"bugs": {
"url": "https://github.com/farm-fe/farm/issues"
}
}
}
18 changes: 13 additions & 5 deletions packages/create-farm/npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-farm-darwin-x64",
"version": "0.0.0",
"version": "0.0.12",
"os": [
"darwin"
],
Expand All @@ -11,8 +11,16 @@
"files": [
"create-farm.darwin-x64.node"
],
"license": "MIT",
"engines": {
"node": ">= 10"
"description": "Rapidly create a new farm project.",
"keywords": [
"farm",
"create-farm"
],
"author": "",
"homepage": "https://www.farmfe.org/docs/quick-start#create-a-farm-project",
"license": "ISC",
"repository": "https://github.com/farm-fe/farm/tree/main/packages/create-farm",
"bugs": {
"url": "https://github.com/farm-fe/farm/issues"
}
}
}
3 changes: 3 additions & 0 deletions packages/create-farm/npm/freebsd-x64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `create-farm-freebsd-x64`

This is the **x86_64-unknown-freebsd** binary for `create-farm`
26 changes: 26 additions & 0 deletions packages/create-farm/npm/freebsd-x64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "create-farm-freebsd-x64",
"version": "0.0.12",
"os": [
"freebsd"
],
"cpu": [
"x64"
],
"main": "create-farm.freebsd-x64.node",
"files": [
"create-farm.freebsd-x64.node"
],
"description": "Rapidly create a new farm project.",
"keywords": [
"farm",
"create-farm"
],
"author": "",
"homepage": "https://www.farmfe.org/docs/quick-start#create-a-farm-project",
"license": "ISC",
"repository": "https://github.com/farm-fe/farm/tree/main/packages/create-farm",
"bugs": {
"url": "https://github.com/farm-fe/farm/issues"
}
}
Loading

0 comments on commit a785d6f

Please sign in to comment.