Skip to content

Commit

Permalink
Split CLI into its own crate
Browse files Browse the repository at this point in the history
- This allows using the library without depending on the `getopts` and `vergen` trees
- Rename executable
- Update CI for cargo workspace
- Update build scripts in root for workspace compatibility
- Always run CI
  • Loading branch information
parasyte committed Aug 12, 2021
1 parent 3d61bc5 commit 08aefdf
Show file tree
Hide file tree
Showing 14 changed files with 511 additions and 434 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/nightly_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# uses: actions-rs/cargo@v1
# with:
# command: test
# args: --release --verbose
# args: --release --verbose --workspace
#
# - name: Get previous nightly Release info
# uses: octokit/[email protected]
Expand Down Expand Up @@ -73,7 +73,7 @@
# with:
# use-cross: true
# command: build
# args: --release --verbose --target=x86_64-pc-windows-gnu
# args: --release --verbose --package customasm-cli --target=x86_64-pc-windows-gnu
#
# - name: Create remote nightly tag
# env:
Expand Down Expand Up @@ -114,4 +114,4 @@
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./pkg/pkg.zip
# asset_name: customasm_${{ env.RELEASE_TAG }}_win64.zip
# asset_content_type: application/zip
# asset_content_type: application/zip
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --release --verbose
args: --release --verbose --workspace

- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --verbose --target=x86_64-pc-windows-gnu
args: --release --verbose --package customasm-cli --target=x86_64-pc-windows-gnu

- name: Create Release
id: create_release
Expand Down Expand Up @@ -65,4 +65,4 @@ jobs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pkg/pkg.zip
asset_name: customasm_win64.zip
asset_content_type: application/zip
asset_content_type: application/zip
14 changes: 2 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@ name: Test Build

on:
push:
branches:
- master
- dev
- 'dev-*'
- 'feature-*'
pull_request:
branches:
- master
- dev
- 'dev-*'
- 'feature-*'

jobs:
build:
Expand All @@ -22,6 +12,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build
run: cargo build --verbose
run: cargo build --verbose --workspace
- name: Run tests
run: cargo test --verbose
run: cargo test --verbose --workspace
13 changes: 5 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository = "https://github.com/hlorenzi/customasm"
readme = "README.md"
license = "Apache-2.0"
keywords = ["asm", "assembler", "assembly", "custom"]
categories = ["command-line-utilities", "hardware-support"]
categories = ["hardware-support"]
exclude = ["web/*"]
build = "src/build.rs"

Expand All @@ -18,18 +18,15 @@ crate-type = ["lib", "cdylib"]
name = "customasm"
path = "src/lib.rs"

[[bin]]
name = "customasm"
path = "src/main.rs"

[dependencies]
getopts = "0.2.17"
num-bigint = { version = "0.1", default_features = false }
num-traits = { version = "0.1", default_features = false }
num-integer = { version = "0.1", default_features = false }

[dev-dependencies]
sha2 = "0.9.1"

[build-dependencies]
vergen = "3.1.0"
[workspace]
members = [
"customasm-cli",
]
4 changes: 2 additions & 2 deletions build_ghpages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Remove-Item -Path .gitignore
Copy-Item -Path .gitignore.ghpages -Destination .gitignore

# Build wasm binary
cargo build --lib --target wasm32-unknown-unknown --release
cargo build --lib --target wasm32-unknown-unknown --release --workspace

# Reduce binary size
wasm-gc "./target/wasm32-unknown-unknown/release/customasm.wasm" -o "./target/wasm32-unknown-unknown/release/customasm.gc.wasm"
Expand All @@ -21,4 +21,4 @@ git commit -m "build GitHub Pages"
git push -f origin ghpages

# Return to main branch
git checkout main
git checkout main
2 changes: 1 addition & 1 deletion build_wasm.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build wasm binary
cargo build --lib --target wasm32-unknown-unknown --release
cargo build --lib --target wasm32-unknown-unknown --release --workspace

# Reduce binary size
wasm-gc "./target/wasm32-unknown-unknown/release/customasm.wasm" -o "./target/wasm32-unknown-unknown/release/customasm.gc.wasm"
Expand Down
22 changes: 22 additions & 0 deletions customasm-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "customasm-cli"
version = "0.11.10"
edition = "2018"
authors = ["hlorenzi <https://hlorenzi.com>"]
description = "An assembler for custom, user-defined instruction sets!"
homepage = "https://github.com/hlorenzi/customasm"
repository = "https://github.com/hlorenzi/customasm"
license = "Apache-2.0"
keywords = ["asm", "assembler", "assembly", "custom"]
categories = ["command-line-utilities", "hardware-support"]

[dependencies]
customasm = { path = "../" }
getopts = "0.2.17"

[build-dependencies]
vergen = "3.1.0"

[[bin]]
name = "customasm"
path = "src/main.rs"
16 changes: 16 additions & 0 deletions customasm-cli/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extern crate vergen;


use vergen::{generate_cargo_keys, ConstantsFlags};


fn main()
{
let mut flags = ConstantsFlags::empty();
flags.toggle(ConstantsFlags::REBUILD_ON_HEAD_CHANGE);
flags.toggle(ConstantsFlags::SEMVER_LIGHTWEIGHT);
flags.toggle(ConstantsFlags::COMMIT_DATE);
flags.toggle(ConstantsFlags::TARGET_TRIPLE);

generate_cargo_keys(flags).expect("Unable to generate the cargo keys!");
}
Loading

0 comments on commit 08aefdf

Please sign in to comment.