Skip to content

Commit

Permalink
Cross-compile to arm (#49)
Browse files Browse the repository at this point in the history
* Cross-compile to arm

* fix linter warnings

* inc version
  • Loading branch information
koshelev authored Feb 27, 2023
1 parent 40fe552 commit 1aee1ff
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
35 changes: 27 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install stable toolchain linux
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Run tests
run: cargo test --verbose

release-linux:
runs-on: ubuntu-latest
needs: tests
strategy:
matrix:
target: [ aarch64-unknown-linux-musl, x86_64-unknown-linux-musl ]
steps:
- name: Checkout
uses: actions/checkout@v1
Expand All @@ -29,30 +38,40 @@ jobs:
uses: actions/[email protected]
with:
path: target
key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
key: ${{ matrix.target }}-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-build-
${{ matrix.target }}-build-
- name: Install stable toolchain linux
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: x86_64-unknown-linux-musl
target: ${{ matrix.target }}

- name: Build for release linux
- name: Install musl-tools
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
cargo build --release --target=x86_64-unknown-linux-musl
mv target/x86_64-unknown-linux-musl/release bin/
tar -czvf protofetch_linux_amd64.tar.gz bin/protofetch
- name: Build target
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target ${{ matrix.target }}

- name: Package
run: |
mv target/${{ matrix.target }}/release bin/
tar -czvf protofetch_${{ matrix.target }}.tar.gz bin/protofetch
- name: Upload release
uses: softprops/action-gh-release@v1
with:
files: |
protofetch_linux_amd64.tar.gz
protofetch_${{ matrix.target }}.tar.gz
release-mac-arm:
runs-on: macos-latest
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "protofetch"
version = "0.0.20"
version = "0.0.21"
edition = "2018"
license = "Apache-2.0"
description = "A source dependency management tool for Protobuf."
Expand Down
6 changes: 1 addition & 5 deletions src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ fn pruned_transitive_dependencies(
dep: &LockedDependency,
lockfile: &LockFile,
visited: &mut HashSet<PathBuf>,
visited_dep: &mut HashSet<LockedDependency>,
found_proto_deps: &mut HashSet<ProtoFileCanonicalMapping>,
) -> Result<(), ProtoError> {
let dep_dir = cache_src_dir.join(&dep.name.value).join(&dep.commit_hash);
Expand Down Expand Up @@ -160,7 +159,6 @@ fn pruned_transitive_dependencies(
dep,
lockfile,
visited,
visited_dep,
found_proto_deps,
)?;
}
Expand Down Expand Up @@ -192,7 +190,6 @@ fn pruned_transitive_dependencies(
dep,
lockfile,
&mut visited,
&mut visited_dep,
&mut found_proto_deps,
)?;
}
Expand All @@ -212,7 +209,6 @@ fn pruned_transitive_dependencies(
&t_dep,
lockfile,
&mut visited,
&mut visited_dep,
&mut found_proto_deps,
)?;
}
Expand Down Expand Up @@ -266,7 +262,7 @@ fn extract_proto_dependencies_from_file(file: &Path) -> Result<Vec<PathBuf>, Pro
while reader.read_line(&mut line)? > 0 {
if line.starts_with("import ") {
if let Some(dependency) = line.split_whitespace().nth(1) {
let dependency = dependency.to_string().replace(';', "").replace('\"', "");
let dependency = dependency.to_string().replace([';', '\"'], "");
dependencies.push(PathBuf::from(dependency));
}
}
Expand Down

0 comments on commit 1aee1ff

Please sign in to comment.