Skip to content

Commit

Permalink
Merge pull request #28 from deevus/cargo-toml-rustflags
Browse files Browse the repository at this point in the history
Create config.toml for rustflags
  • Loading branch information
deevus authored Jan 23, 2025
2 parents 4719c7d + 0ebeffe commit 531b7c9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ name: Build Zed Nightly
on:
schedule:
- cron: "0 0 * * *" # Runs every night at midnight UTC
push:
branches:
- main
workflow_dispatch:
pull_request:

jobs:
build:
Expand All @@ -32,11 +31,15 @@ jobs:
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout self
uses: actions/checkout@v4

- name: Checkout Zed
uses: actions/checkout@v4
with:
repository: zed-industries/zed
ref: main
path: zed

- name: Install rust nightly
uses: dtolnay/rust-toolchain@stable
Expand All @@ -49,21 +52,25 @@ jobs:
uses: Swatinem/rust-cache@v2.7.3
with:
key: ${{ matrix.backend }}
workspaces: "zed -> target"

- name: Setup rustflags
run: pwsh ./Parse-Rustflags.ps1 ${{ matrix.rustflags }}

- name: Build release
env:
RUSTFLAGS: ${{ matrix.rustflags }}
working-directory: zed
run: cargo build --release

- name: Archive build
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: target/release/zed.exe
path: zed/target/release/zed.exe

release:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions:
contents: write

Expand Down Expand Up @@ -94,4 +101,4 @@ jobs:
make_latest: true
files: |
zed-windows.zip
zed-windows-opengl.zip
zed-windows-opengl.zip
19 changes: 19 additions & 0 deletions Parse-Rustflags.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$rustflags = $args

if ($rustflags.Length -eq 0) {
Write-Host "No rustflags provided"
exit 0
}

$config_path = ".cargo/config.toml"

New-Item -Path $config_path -Force | Out-Null

"[target.'cfg(all())']" | Out-File -FilePath $config_path -Append | Out-Null

"rustflags = [" | Out-File -FilePath $config_path -Append -NoNewLine | Out-Null
foreach ($flag in $rustflags) {
$line = """${flag}"", "
$line | Out-File -FilePath $config_path -Append -NoNewLine | Out-Null
}
"]" | Out-File -FilePath $config_path -Append | Out-Null

0 comments on commit 531b7c9

Please sign in to comment.