mirror of
https://github.com/rustmailer/rustmailer.git
synced 2026-09-06 08:01:13 +00:00
build: support PROTOC_INCLUDE override and improve build.rs robustness
This commit is contained in:
@@ -42,8 +42,8 @@ jobs:
|
||||
PROTOC_VERSION=31.1
|
||||
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip
|
||||
unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d protoc
|
||||
sudo mv protoc/bin/protoc /usr/local/bin/
|
||||
sudo cp -r protoc/include/* /usr/local/include/
|
||||
echo "${PWD}/protoc/bin" >> $GITHUB_PATH
|
||||
echo "PROTOC_INCLUDE=$PWD/protoc/include" >> $GITHUB_ENV
|
||||
protoc --version
|
||||
|
||||
- name: Install protoc on macOS
|
||||
@@ -51,17 +51,23 @@ jobs:
|
||||
run: |
|
||||
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v31.1/protoc-31.1-osx-x86_64.zip
|
||||
unzip protoc-31.1-osx-x86_64.zip -d protoc
|
||||
sudo mv protoc/bin/protoc /usr/local/bin/
|
||||
sudo cp -r protoc/include/* /usr/local/include/
|
||||
echo "${PWD}/protoc/bin" >> $GITHUB_PATH
|
||||
echo "PROTOC_INCLUDE=$PWD/protoc/include" >> $GITHUB_ENV
|
||||
protoc --version
|
||||
|
||||
- name: Install protoc on Windows
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: |
|
||||
Invoke-WebRequest -Uri https://github.com/protocolbuffers/protobuf/releases/download/v31.1/protoc-31.1-win64.zip -OutFile protoc.zip
|
||||
Expand-Archive protoc.zip -DestinationPath protoc
|
||||
$Env:PATH += ";${PWD}/protoc/bin"
|
||||
protoc --version
|
||||
Invoke-WebRequest -Uri https://github.com/protocolbuffers/protobuf/releases/download/v31.1/protoc-31.1-win64.zip -OutFile protoc.zip
|
||||
Expand-Archive protoc.zip -DestinationPath protoc
|
||||
$protocPath = Join-Path $PWD "protoc\\bin"
|
||||
$includePath = Join-Path $PWD "protoc\\include"
|
||||
|
||||
Add-Content $env:GITHUB_PATH $protocPath
|
||||
Add-Content $env:GITHUB_ENV "PROTOC_INCLUDE=$includePath"
|
||||
& "$protocPath\\protoc.exe" --version
|
||||
|
||||
|
||||
- name: Setup Node.js & pnpm
|
||||
uses: actions/setup-node@v4
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
use std::{io::Result, process::Command};
|
||||
use std::{env, io::Result, process::Command};
|
||||
|
||||
use poem_grpc_build::Config;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let mut includes = vec!["./protos".to_string()];
|
||||
if let Ok(protoc_include) = env::var("PROTOC_INCLUDE") {
|
||||
includes.push(protoc_include);
|
||||
}
|
||||
// Convert Vec<String> to Vec<&str>
|
||||
let includes_ref: Vec<&str> = includes.iter().map(|s| s.as_str()).collect();
|
||||
Config::new()
|
||||
.file_descriptor_set_path("rustmailer.bin")
|
||||
.compile(&["./protos/rustmailer.proto"], &["./protos"])?;
|
||||
.compile(&["./protos/rustmailer.proto"], &includes_ref)?;
|
||||
|
||||
let output = Command::new("git")
|
||||
.args(&["rev-parse", "--short", "HEAD"])
|
||||
|
||||
Reference in New Issue
Block a user