-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
1,743 additions
and
0 deletions.
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,32 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get version from Cargo.toml | ||
id: get_version | ||
run: echo VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="xtlid") | .version') >> $GITHUB_ENV | ||
|
||
- name: Log in to crates.io | ||
run: cargo login ${{ secrets.CRATES_IO_TOKEN }} | ||
|
||
- name: Publish crate | ||
run: cargo publish | ||
|
||
- name: Create GitHub Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
tag_name: ${{ env.VERSION }} | ||
files: src/xtlid.xml | ||
env: | ||
GITHUB_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,2 @@ | ||
/target | ||
/src/xtlid.rs |
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,13 @@ | ||
[package] | ||
name = "xtlid" | ||
version = "0.1.1" | ||
authors = ["Stefan Schmidt"] | ||
edition = "2021" | ||
license = "MIT" | ||
description = "Provides a mapping of IDs to function names for .XTLID-sections found in Xbox executables" | ||
|
||
[dependencies] | ||
phf = {version= " 0.11.2", features = ["macros"]} | ||
|
||
[build-dependencies] | ||
xmltree = "0.10" |
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,45 @@ | ||
use std::fs; | ||
use std::{env, path::Path}; | ||
use xmltree::Element; | ||
|
||
fn main() { | ||
let out_dir = env::var_os("OUT_DIR").unwrap(); | ||
let dest_path = Path::new(&out_dir).join("xtlid.rs"); | ||
|
||
let input = fs::read_to_string("src/xtlid.xml").unwrap(); | ||
let xtlid_element = Element::parse(input.as_bytes()).unwrap(); | ||
|
||
let mut output = String::new(); | ||
|
||
output.push_str("use phf::phf_map;\n\n"); | ||
output.push_str("pub static XTLIDS: phf::Map<u32, &str> = phf_map! {\n"); | ||
|
||
for lib_node in xtlid_element.children.iter() { | ||
match lib_node { | ||
xmltree::XMLNode::Element(child_element) => { | ||
if child_element.name == "lib" { | ||
for func_node in child_element.children.iter() { | ||
match func_node { | ||
xmltree::XMLNode::Element(func_node) => { | ||
if func_node.name == "func" { | ||
let id = func_node.attributes.get("id").unwrap(); | ||
let name = func_node.attributes.get("name").unwrap(); | ||
output.push_str(&format!(" {}u32 => \"{}\",\n", id, name)); | ||
} | ||
} | ||
_ => {} | ||
} | ||
} | ||
} | ||
} | ||
_ => {} | ||
} | ||
} | ||
|
||
output.push_str("};\n"); | ||
|
||
fs::write(dest_path, output).unwrap(); | ||
|
||
println!("cargo:rerun-if-changed=src/xtlid.xml"); | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
} |
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 @@ | ||
include!(concat!(env!("OUT_DIR"), "/xtlid.rs")); |
Oops, something went wrong.