Skip to content

Commit ba22624

Browse files
committed
Merge branch 'main' into ohos-main
2 parents b8c7fd5 + 371d94c commit ba22624

File tree

466 files changed

+24635
-2776
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

466 files changed

+24635
-2776
lines changed

.github/workflows/ci.yml

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, ohos-main ]
6+
pull_request:
7+
branches: [ main, ohos-main ]
8+
9+
jobs:
10+
lint:
11+
name: Lint & Analyze
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
19+
20+
- name: Setup Flutter
21+
uses: subosito/flutter-action@v2
22+
with:
23+
flutter-version: '3.38.7'
24+
channel: 'stable'
25+
cache: true
26+
27+
- name: Install melos
28+
run: dart pub global activate melos
29+
30+
- name: Add melos to PATH
31+
run: echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
32+
33+
- name: Verify melos installation
34+
run: dart pub global run melos --version
35+
36+
- name: Bootstrap melos
37+
run: dart pub global run melos bootstrap
38+
39+
- name: Check code formatting
40+
run: dart pub global run melos run format
41+
42+
- name: Analyze code
43+
run: dart pub global run melos run analyze
44+
45+
test:
46+
name: Test (${{ matrix.os }})
47+
runs-on: ${{ matrix.os }}
48+
strategy:
49+
fail-fast: false
50+
matrix:
51+
os: [ubuntu-latest, macos-latest, windows-latest]
52+
53+
steps:
54+
- name: Checkout repository
55+
uses: actions/checkout@v4
56+
with:
57+
submodules: recursive
58+
59+
- name: Setup Flutter
60+
uses: subosito/flutter-action@v2
61+
with:
62+
flutter-version: '3.38.7'
63+
channel: 'stable'
64+
cache: true
65+
66+
- name: Install melos
67+
run: dart pub global activate melos
68+
69+
- name: Add melos to PATH
70+
shell: bash
71+
run: |
72+
if [[ "$RUNNER_OS" == "Windows" ]]; then
73+
echo "$USERPROFILE/.pub-cache/bin" >> $GITHUB_PATH
74+
else
75+
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
76+
fi
77+
78+
- name: Verify melos installation
79+
run: dart pub global run melos --version
80+
81+
- name: Bootstrap melos
82+
run: dart pub global run melos bootstrap
83+
84+
- name: Run tests
85+
run: dart pub global run melos run test
86+
87+
build:
88+
name: Build (${{ matrix.os }})
89+
runs-on: ${{ matrix.os }}
90+
needs: [lint]
91+
strategy:
92+
fail-fast: false
93+
matrix:
94+
os: [ubuntu-latest, macos-latest, windows-latest]
95+
96+
steps:
97+
- name: Checkout repository
98+
uses: actions/checkout@v4
99+
with:
100+
submodules: recursive
101+
102+
- name: Setup Flutter
103+
uses: subosito/flutter-action@v2
104+
with:
105+
flutter-version: '3.38.7'
106+
channel: 'stable'
107+
cache: true
108+
109+
- name: Install melos
110+
run: dart pub global activate melos
111+
112+
- name: Add melos to PATH
113+
shell: bash
114+
run: |
115+
if [[ "$RUNNER_OS" == "Windows" ]]; then
116+
echo "$USERPROFILE/.pub-cache/bin" >> $GITHUB_PATH
117+
else
118+
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
119+
fi
120+
121+
- name: Bootstrap melos
122+
run: dart pub global run melos bootstrap
123+
124+
- name: Setup Java for Android
125+
if: matrix.os == 'ubuntu-latest'
126+
uses: actions/setup-java@v4
127+
with:
128+
distribution: 'temurin'
129+
java-version: '17'
130+
131+
- name: Install Linux dependencies
132+
if: matrix.os == 'ubuntu-latest'
133+
run: |
134+
sudo apt-get update
135+
sudo apt-get install -y \
136+
libgtk-3-dev \
137+
libblkid-dev \
138+
liblzma-dev \
139+
pkg-config \
140+
cmake \
141+
ninja-build \
142+
clang
143+
144+
- name: Build cnativeapi example Android
145+
if: matrix.os == 'ubuntu-latest'
146+
run: |
147+
cd packages/cnativeapi/example
148+
flutter build apk --release
149+
150+
- name: Build cnativeapi example iOS
151+
if: matrix.os == 'macos-latest'
152+
run: |
153+
cd packages/cnativeapi/example
154+
flutter build ios --release --no-codesign
155+
156+
- name: Build cnativeapi example Linux
157+
if: matrix.os == 'ubuntu-latest'
158+
run: |
159+
cd packages/cnativeapi/example
160+
flutter build linux --release
161+
162+
- name: Build cnativeapi example macOS
163+
if: matrix.os == 'macos-latest'
164+
run: |
165+
cd packages/cnativeapi/example
166+
flutter build macos --release
167+
168+
- name: Build cnativeapi example Windows
169+
if: matrix.os == 'windows-latest'
170+
run: |
171+
cd packages/cnativeapi/example
172+
flutter build windows --release
173+
174+
- name: Build nativeapi example Android
175+
if: matrix.os == 'ubuntu-latest'
176+
run: |
177+
cd packages/nativeapi/example
178+
flutter build apk --release
179+
180+
- name: Build nativeapi example iOS
181+
if: matrix.os == 'macos-latest'
182+
run: |
183+
cd packages/nativeapi/example
184+
flutter build ios --release --no-codesign
185+
186+
- name: Build nativeapi example Linux
187+
if: matrix.os == 'ubuntu-latest'
188+
run: |
189+
cd packages/nativeapi/example
190+
flutter build linux --release
191+
192+
- name: Build nativeapi example macOS
193+
if: matrix.os == 'macos-latest'
194+
run: |
195+
cd packages/nativeapi/example
196+
flutter build macos --release
197+
198+
- name: Build nativeapi example Windows
199+
if: matrix.os == 'windows-latest'
200+
run: |
201+
cd packages/nativeapi/example
202+
flutter build windows --release

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "packages/cnativeapi/src/libnativeapi"]
2-
path = packages/cnativeapi/src/libnativeapi
1+
[submodule "packages/cnativeapi/cxx_impl"]
2+
path = packages/cnativeapi/cxx_impl
33
url = https://github.com/libnativeapi/nativeapi.git

README-ZH.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# nativeapi
2+
3+
[nativeapi](https://github.com/libnativeapi/libnativeapi) 的 Flutter 绑定 - 提供无缝、统一的原生系统 API 访问。
4+
5+
🚧 **开发中**: 此包目前正在积极开发中。
6+
7+
## 快速开始
8+
9+
`pubspec.yaml` 中添加 `nativeapi`:
10+
11+
```yaml
12+
dependencies:
13+
nativeapi: ^0.1.0
14+
```
15+
16+
然后运行:
17+
18+
```bash
19+
flutter pub get
20+
```
21+
22+
### 使用方法
23+
24+
> 📖 详细的文档和示例即将推出!
25+
26+
```dart
27+
import 'package:nativeapi/nativeapi.dart';
28+
29+
// 示例用法将在此处添加
30+
```
31+
32+
## 开发
33+
34+
### 前置要求
35+
36+
- Flutter (>=3.35.0)
37+
- Dart SDK (>=3.9.0)
38+
39+
### 设置
40+
41+
1. 克隆仓库:
42+
43+
```bash
44+
git clone https://github.com/libnativeapi/nativeapi-flutter.git
45+
cd nativeapi-flutter
46+
```
47+
48+
2. 初始化子模块:
49+
50+
```bash
51+
git submodule update --init --recursive
52+
```
53+
54+
3. 安装依赖:
55+
56+
```bash
57+
melos bootstrap
58+
```
59+
60+
4. 运行示例应用:
61+
62+
```bash
63+
cd examples/display_example
64+
flutter run
65+
```
66+
67+
### FFI 绑定
68+
69+
本项目使用 ffigen 从 C 头文件生成 Dart FFI 绑定。要重新生成绑定:
70+
71+
```bash
72+
cd packages/cnativeapi
73+
dart run ffigen --config ffigen.yaml
74+
```
75+
76+
ffigen 配置定义在 `packages/cnativeapi/ffigen.yaml` 中。通常在以下情况下需要重新生成绑定:
77+
- 原生 C 库 ([libnativeapi/nativeapi](https://github.com/libnativeapi/nativeapi)) 更新时
78+
- ffigen 配置被修改时
79+
80+
## 许可证
81+
82+
[MIT](./LICENSE)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Add `nativeapi` to your `pubspec.yaml`:
1010

1111
```yaml
1212
dependencies:
13-
nativeapi: ^0.1.0-dev.1
13+
nativeapi: ^0.1.0
1414
```
1515
1616
Then run:
@@ -74,7 +74,7 @@ dart run ffigen --config ffigen.yaml
7474
```
7575

7676
The ffigen configuration is defined in `packages/cnativeapi/ffigen.yaml`. You typically need to regenerate bindings when:
77-
- The native C library (libnativeapi) is updated
77+
- The native C library ([libnativeapi/nativeapi](https://github.com/libnativeapi/nativeapi)) is updated
7878
- The ffigen configuration is modified
7979

8080
## License
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
21
#include "Generated.xcconfig"
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
21
#include "Generated.xcconfig"

examples/display_example/ios/Podfile.lock

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)