mirror of
https://github.com/danog/dart-sass.git
synced 2024-11-30 04:39:03 +01:00
Use buf instead of protoc to compile protobufs (#146)
This is more consistent with the embedded host, and avoids relying on the seldom-maintaned arduino/setup-protoc GitHub action.
This commit is contained in:
parent
487753ebe4
commit
f50a3f0da3
43
.github/workflows/ci.yml
vendored
43
.github/workflows/ci.yml
vendored
@ -3,9 +3,6 @@ name: CI
|
||||
defaults:
|
||||
run: {shell: bash}
|
||||
|
||||
env:
|
||||
protoc_version: '3.x'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, feature.*]
|
||||
@ -28,8 +25,8 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: frenck/action-setup-yq@v1
|
||||
with: {version: v4.30.5} # frenck/action-setup-yq#35
|
||||
- uses: arduino/setup-protoc@v1
|
||||
with: { version: "${{ env.protoc_version }}", repo-token: "${{ github.token }}" }
|
||||
- uses: bufbuild/buf-setup-action@v1.13.1
|
||||
with: {github_token: "${{ github.token }}"}
|
||||
- uses: dart-lang/setup-dart@v1
|
||||
with: {sdk: "${{ matrix.dart_channel }}"}
|
||||
|
||||
@ -86,10 +83,8 @@ jobs:
|
||||
with: {sdk: stable}
|
||||
- uses: frenck/action-setup-yq@v1
|
||||
with: {version: v4.30.5} # frenck/action-setup-yq#35
|
||||
- uses: arduino/setup-protoc@v1
|
||||
with:
|
||||
version: ${{ env.PROTOC_VERSION }}
|
||||
repo-token: '${{ github.token }}'
|
||||
- uses: bufbuild/buf-setup-action@v1.13.1
|
||||
with: {github_token: "${{ github.token }}"}
|
||||
|
||||
- name: Check out Dart Sass only if linked in the PR description
|
||||
uses: sass/clone-linked-repo@v1
|
||||
@ -161,8 +156,8 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: frenck/action-setup-yq@v1
|
||||
with: {version: v4.30.5} # frenck/action-setup-yq#35
|
||||
- uses: arduino/setup-protoc@v1
|
||||
with: { version: "${{ env.protoc_version }}", repo-token: "${{ github.token }}" }
|
||||
- uses: bufbuild/buf-setup-action@v1.13.1
|
||||
with: {github_token: "${{ github.token }}"}
|
||||
- uses: dart-lang/setup-dart@v1
|
||||
|
||||
- name: Check out Dart Sass only if linked in the PR description
|
||||
@ -210,20 +205,11 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: arduino/setup-protoc@v1
|
||||
with: { version: "${{ env.protoc_version }}", repo-token: "${{ github.token }}" }
|
||||
- uses: bufbuild/buf-setup-action@v1.13.1
|
||||
with: {github_token: "${{ github.token }}"}
|
||||
- uses: dart-lang/setup-dart@v1
|
||||
- run: dart pub get
|
||||
- run: dart run grinder protobuf
|
||||
# We need to upload the compiled protobuf rather than recompiling it on
|
||||
# other platforms because arduino/setup-protoc currently) requires Node 12
|
||||
# which doesn't support ARM.
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: embedded-protocol
|
||||
path: |
|
||||
build/embedded-protocol
|
||||
lib/src/embedded_sass.*.dart
|
||||
- name: Deploy
|
||||
run: dart run grinder pkg-github-release pkg-github-linux-ia32 pkg-github-linux-x64
|
||||
env: {GH_BEARER_TOKEN: "${{ github.token }}"}
|
||||
@ -243,9 +229,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: embedded-protocol
|
||||
- uses: bufbuild/buf-setup-action@v1.13.1
|
||||
with: {github_token: "${{ github.token }}"}
|
||||
- run: dart pub get
|
||||
- run: dart pub grinder protobuf
|
||||
- uses: docker/setup-qemu-action@v2
|
||||
- name: Deploy
|
||||
run: |
|
||||
@ -278,14 +265,14 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: embedded-protocol
|
||||
- uses: bufbuild/buf-setup-action@v1.13.1
|
||||
with: {github_token: "${{ github.token }}"}
|
||||
- uses: dart-lang/setup-dart@v1
|
||||
# Workaround for dart-lang/setup-dart#59
|
||||
with:
|
||||
architecture: ${{ matrix.architecture }}
|
||||
- run: dart pub get
|
||||
- run: dart pub run grinder protobuf
|
||||
- name: Deploy
|
||||
run: dart run grinder pkg-github-${{ matrix.platform }}
|
||||
env: {GH_BEARER_TOKEN: "${{ github.token }}"}
|
||||
|
16
README.md
16
README.md
@ -13,6 +13,22 @@ and importers.
|
||||
- `dart-sass-embedded` starts the compiler and listens on stdin.
|
||||
- `dart-sass-embedded --version` prints `versionResponse` with `id = 0` in JSON and exits.
|
||||
|
||||
### Development
|
||||
|
||||
To run the embedded compiler from source:
|
||||
|
||||
* Run `dart pub get`.
|
||||
|
||||
* [Install `buf`].
|
||||
|
||||
* Run `dart run grinder protobuf`.
|
||||
|
||||
From there, you can either run `dart bin/dart_sass_embedded.dart` directly or
|
||||
`dart run grinder pkg-standalone-dev` to build a compiled development
|
||||
executable.
|
||||
|
||||
[Install `buf`]: https://docs.buf.build/installation
|
||||
|
||||
### Releases
|
||||
|
||||
Binary releases are available from the [GitHub release page]. We recommend that
|
||||
|
4
buf.gen.yaml
Normal file
4
buf.gen.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
version: v1
|
||||
plugins:
|
||||
- plugin: dart
|
||||
out: lib/src
|
2
buf.work.yaml
Normal file
2
buf.work.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
version: v1
|
||||
directories: [build/embedded-protocol]
|
@ -51,11 +51,13 @@ Future<void> protobuf() async {
|
||||
if (Platform.isWindows) {
|
||||
File('build/protoc-gen-dart.bat').writeAsStringSync('''
|
||||
@echo off
|
||||
dart pub run protoc_plugin %*
|
||||
dart run protoc_plugin %*
|
||||
''');
|
||||
} else {
|
||||
File('build/protoc-gen-dart')
|
||||
.writeAsStringSync('dart pub run protoc_plugin "\$@"');
|
||||
File('build/protoc-gen-dart').writeAsStringSync('''
|
||||
#!/bin/sh
|
||||
dart run protoc_plugin "\$@"
|
||||
''');
|
||||
run('chmod', arguments: ['a+x', 'build/protoc-gen-dart']);
|
||||
}
|
||||
|
||||
@ -63,12 +65,8 @@ dart pub run protoc_plugin %*
|
||||
await cloneOrPull("https://github.com/sass/embedded-protocol.git");
|
||||
}
|
||||
|
||||
await runAsync("protoc",
|
||||
arguments: [
|
||||
"-Ibuild/embedded-protocol",
|
||||
"embedded_sass.proto",
|
||||
"--dart_out=lib/src/"
|
||||
],
|
||||
await runAsync("buf",
|
||||
arguments: ["generate"],
|
||||
runOptions: RunOptions(environment: {
|
||||
"PATH": 'build' +
|
||||
(Platform.isWindows ? ";" : ":") +
|
||||
|
Loading…
Reference in New Issue
Block a user