-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo zigbuild #799
Closed
Closed
cargo zigbuild #799
Changes from 7 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
135896a
zig-release
phoepsilonix 0c71660
Merge branch 'raphlinus:master' into zig-release
phoepsilonix 24f9fb1
Merge branch 'raphlinus:master' into zig-release
phoepsilonix ee2fdda
Merge branch 'raphlinus:master' into zig-release
phoepsilonix 11dc325
branch_0.9.3 v0.9.6
phoepsilonix f6008ac
Merge branch 'raphlinus:master' into zig-release
phoepsilonix 41f3c6a
v0.10.0
phoepsilonix fc1269e
git pull upstream --tags
phoepsilonix a5b17ec
workflow
phoepsilonix 16a2b16
v0.9.6
phoepsilonix aba1f68
release
phoepsilonix b5c8f9a
Merge branch 'raphlinus:master' into zig-release
phoepsilonix caca086
tag and commit
phoepsilonix 13b3ff0
tag and commit
phoepsilonix 686906a
Merge branch 'zig-release' of github.com:phoepsilonix/pulldown-cmark …
phoepsilonix 11e3ead
ziglang update dev.3076
phoepsilonix deaa2cd
remove cargo update
phoepsilonix b170516
install binutils-mingw-w64
phoepsilonix ae550c3
update zigland 0.11.0
phoepsilonix 602a44f
modified version
phoepsilonix 561a517
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix ae42808
fix version.txt
phoepsilonix b3ab681
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix d15af09
tag -> version
phoepsilonix 5c573db
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix 9d9f734
mold 2.4.1,sccache 0.7.7
phoepsilonix f77d6c2
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix 8e4e0df
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix baffc5e
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix b4841a3
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix 7c42e35
mold update
phoepsilonix b0adc4e
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix 3327b72
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix 119fc64
tag fix
phoepsilonix 79094b0
Fine-tuning tags
phoepsilonix 3c69820
sccache update
phoepsilonix e8fd7bf
submodule is no needed
phoepsilonix 17cbb2b
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix a5c0f2e
tag flow
phoepsilonix 7c1c390
disable rust workflow
phoepsilonix b168d71
.gitignore
phoepsilonix 83885d4
tag flow fix
phoepsilonix e955c1e
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix 460c50f
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix ae118e9
version tag fix
phoepsilonix 48d00b0
Merge branch 'pulldown-cmark:master' into zig-release
phoepsilonix File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
env: | ||
RUSTC_WRAPPER: sccache | ||
SCCACHE_CACHE_SIZE: 1G | ||
SCCACHE_DIR: /home/runner/.cache/sccache | ||
# SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
submodules: 'recursive' | ||
path: zig-release | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: master | ||
lft: true | ||
submodule: 'recursive' | ||
commit: 42bff71ea497c493d740324ebe4b3799dc273b8a | ||
path: pulldown-cmark | ||
- name: copy Makefile for zig-release | ||
run: | | ||
mkdir -p source | ||
cd zig-release | ||
git describe --tags | sed -e 's/^v//g' -e 's/-g.*$//g' -e 's/-/./g' > version.txt | ||
git describe --tags | sed -e 's/^v//g' -e 's/-g.*$//g' -e 's/-/./g' | ||
cat version.txt | ||
cp Makefile archive.sh target.txt version.txt ../pulldown-cmark/ | ||
cp config.toml target.txt ../ | ||
- name: install zig and tools (Linux) | ||
run: | | ||
#pacman -Sy sudo rustup clang llvm lld make git --noconfirm | ||
sudo apt-get install build-essential make git clang | ||
rm -f ~/.cargo/config* | ||
mkdir -p zig | ||
curl -LZ https://ziglang.org/builds/zig-linux-x86_64-0.12.0-dev.2302+b729a3f00.tar.xz|tar xJ --strip-component=1 -C zig | ||
sudo mv zig /usr/local/ | ||
echo "/usr/local/zig" >> $GITHUB_PATH | ||
- name: Install sccache | ||
env: | ||
LINK: https://github.com/mozilla/sccache/releases/download | ||
SCCACHE_VERSION: 0.7.6 | ||
run: | | ||
SCCACHE_FILE=sccache-v$SCCACHE_VERSION-x86_64-unknown-linux-musl | ||
mkdir -p $HOME/.local/bin | ||
curl -L "$LINK/v$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz | ||
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache | ||
chmod +x $HOME/.local/bin/sccache | ||
echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
- name: Install mold linker | ||
uses: rui314/setup-mold@staging | ||
with: | ||
mold-version: 2.4.0 | ||
make-default: true | ||
- name: Cache toolchain | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Update toolchain | ||
run: | | ||
rustup update nightly | ||
rustup default nightly | ||
rustup component add rust-src | ||
rustup target add $(cat target.txt) | ||
rustup +stable target add $(cat target.txt) | ||
- name: Install cargo-zigbuild | ||
run: | | ||
cargo install cargo-zigbuild --target x86_64-unknown-linux-gnu | ||
- name: config.toml | ||
run: | | ||
mkdir -p ~/.cargo/ | ||
rm -f ~/.cargo/config* | ||
cp config.toml ~/.cargo/config.toml | ||
- name: fix duplicate symbol | ||
run: | | ||
sudo sed -e "s|\(void __cdecl _tzset(void)\)|/*\n\1|" -e "s|\(void __cdecl tzset(void)\)|*/\n\1|" -i /usr/local/zig/lib/libc/mingw/crt/ucrtbase_compat.c | ||
- name: Build and archive | ||
shell: bash | ||
run: | | ||
cd pulldown-cmark | ||
cargo update | ||
make target-archive | ||
- name: Create release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
omitBody: true | ||
artifacts: 'pulldown-cmark/release/*' | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
TARGET=$(shell cat target.txt) | ||
|
||
.PHONY: lint | ||
lint: | ||
@cargo +nightly clippy | ||
|
||
.PHONY: fix | ||
fix: | ||
@cargo +nightly clippy --fix | ||
|
||
.PHONY: test | ||
test: | ||
@cargo +nightly test | ||
|
||
.PHONY: shellspec | ||
shellspec: | ||
@shellspec | ||
|
||
.PHONY: install | ||
install: | ||
@cargo +nightly install --path . | ||
|
||
.PHONY: check | ||
check: | ||
@cargo +nightly check | ||
|
||
.PHONY: target-add | ||
target-add: | ||
@rustup override set nightly | ||
@rustup target add $(TARGET) | ||
|
||
.PHONY: target-build | ||
target-build: target-add | ||
@for target in $(TARGET); do echo $$target; cargo +nightly zigbuild --release --target $$target || cargo +stable zigbuild --release --target $$target; done | ||
|
||
.PHONY: target-archive | ||
target-archive: target-build | ||
@bash archive.sh $(TARGET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
version=$(cat version.txt) | ||
if [[ "${version}" == "" ]]; then | ||
echo "cannot get version tag from HEAD commit" | ||
exit 1 | ||
fi | ||
bin=$(basename "$(git rev-parse --show-toplevel)") | ||
target="$*" | ||
|
||
if [[ ! -d "release" ]]; then | ||
mkdir "release" | ||
fi | ||
|
||
for target in "$@"; do | ||
archive="${bin}_${version}_${target}" | ||
echo "## make archive ${archive}" | ||
if [[ "$target" == *"windows"* ]]; then | ||
( cd "target/${target}/release/" && zip "../../../release/${archive}.zip" "${bin}.exe" ) | ||
else | ||
( cd "target/${target}/release/" && tar -Jcvf "../../../release/${archive}.tar.xz" "${bin}" ) | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
[build] | ||
target = "x86_64-unknown-linux-musl" | ||
rustc-wrapper = "sccache" | ||
|
||
[unstable] | ||
build-std = ["core", "compiler_builtins", "alloc", "std", "panic_abort"] | ||
build-std-features = ["llvm-libunwind"] | ||
|
||
[target.x86_64-unknown-linux-musl] | ||
linker = "clang" | ||
rustflags = [ | ||
"-Clink-self-contained=on", | ||
"-C", "strip=symbols", | ||
"-C", "no-redzone=y", | ||
"-C", "overflow-checks=y", | ||
"-C", "lto=fat", | ||
"-C", "embed-bitcode=y", | ||
"-C", "codegen-units=1", | ||
"-C", "opt-level=z", | ||
"-C", "control-flow-guard=y", | ||
"-C", "link-args=-fuse-ld=mold -Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIE -fpie -Wl,-z,relro,-z,now", | ||
] | ||
|
||
[target.x86_64-pc-windows-gnu] | ||
linker = "clang" | ||
rustflags = [ | ||
"-C", "strip=symbols", | ||
"-C", "no-redzone=y", | ||
"-C", "overflow-checks=y", | ||
"-C", "lto=fat", | ||
"-C", "embed-bitcode=y", | ||
"-C", "codegen-units=1", | ||
"-C", "opt-level=z", | ||
"-C", "control-flow-guard=y", | ||
"-C", "link-args=-fuse-ld=mold -Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIE -fpie -Wl,-z,relro,-z,now", | ||
] | ||
|
||
[target.x86_64-apple-darwin] | ||
linker = "clang" | ||
rustflags = [ | ||
"-C", "strip=symbols", | ||
"-C", "no-redzone=y", | ||
"-C", "overflow-checks=y", | ||
"-C", "lto=fat", | ||
"-C", "embed-bitcode=y", | ||
"-C", "codegen-units=1", | ||
"-C", "opt-level=z", | ||
"-C", "control-flow-guard=y", | ||
"-C", "link-args=-fuse-ld=mold -Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIE -fpie -Wl,-z,relro,-z,now", | ||
] | ||
|
||
[target.aarch64-apple-darwin] | ||
linker = "clang" | ||
rustflags = [ | ||
"-C", "strip=symbols", | ||
"-C", "no-redzone=y", | ||
"-C", "overflow-checks=y", | ||
"-C", "lto=fat", | ||
"-C", "embed-bitcode=y", | ||
"-C", "codegen-units=1", | ||
"-C", "opt-level=z", | ||
"-C", "control-flow-guard=y", | ||
"-C", "link-args=-fuse-ld=mold -Wp,-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIE -fpie -Wl,-z,relro,-z,now", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
x86_64-unknown-linux-musl | ||
x86_64-pc-windows-gnu | ||
x86_64-apple-darwin | ||
aarch64-apple-darwin |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure what the goal is there but none of this smell right. As someone packaging this for distros and using it myself, this whole pile of changes would just confuse me about how the project was expected to be used. It doesn't need
+nightly
. This Makefile is a thin wrapper around other commands and doesn't support any of the tooling I'd expect an actual Makefile to handle. Most of this feels more like it should go in a Justfile or something for developer jobs, but most of it isn't even build stuff, and the bits that are don't seem to be general purpose.