Skip to content

Commit 44f63cc

Browse files
[typeshare] Support linux-arm64 and support u64 (#1)
* Switching build over to `zigbuild` to support linux arm64 variant * Porting over 1Password#140 to support large number * Adding some default overrides to include base types for stuff such as `HashSet` * Typeshare built for repo * Revert
1 parent 66bdec3 commit 44f63cc

File tree

18 files changed

+188
-79
lines changed

18 files changed

+188
-79
lines changed

.github/workflows/release.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,23 @@ jobs:
8787
include:
8888
- os: ubuntu-20.04
8989
dist-args: --artifacts=global
90+
target: ''
9091
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.4/cargo-dist-v0.0.4-installer.sh | sh
9192
- os: macos-11
9293
dist-args: --artifacts=local --target=aarch64-apple-darwin --target=x86_64-apple-darwin
94+
target: 'aarch64-apple-darwin x86_64-apple-darwin'
9395
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.4/cargo-dist-v0.0.4-installer.sh | sh
9496
- os: ubuntu-20.04
9597
dist-args: --artifacts=local --target=x86_64-unknown-linux-gnu
98+
target: 'x86_64-unknown-linux-gnu'
9699
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.4/cargo-dist-v0.0.4-installer.sh | sh
100+
- os: ubuntu-20.04
101+
dist-args: --artifacts=local --target=aarch64-unknown-linux-gnu
102+
target: 'aarch64-unknown-linux-gnu'
103+
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.4/cargo-dist-v0.0.4-installer.sh | sh
97104
- os: windows-2019
98105
dist-args: --artifacts=local --target=x86_64-pc-windows-msvc
106+
target: 'x86_64-pc-windows-msvc'
99107
install-dist: irm https://github.com/axodotdev/cargo-dist/releases/download/v0.0.4/cargo-dist-v0.0.4-installer.ps1 | iex
100108

101109
runs-on: ${{ matrix.os }}
@@ -108,17 +116,36 @@ jobs:
108116
- name: Install cargo-dist
109117
run: ${{ matrix.install-dist }}
110118
- name: Run cargo-dist
119+
if: ${{ matrix.target != '' }}
111120
# This logic is a bit janky because it's trying to be a polyglot between
112121
# powershell and bash since this will run on windows, macos, and linux!
113122
# The two platforms don't agree on how to talk about env vars but they
114123
# do agree on 'cat' and '$()' so we use that to marshal values between commands.
115124
run: |
116-
# Actually do builds and make zips and whatnot
117-
cargo dist build --tag=${{ github.ref_name }} --output-format=json ${{ matrix.dist-args }} > dist-manifest.json
118-
echo "dist ran successfully"
125+
pip3 install ziglang
126+
cargo install cargo-zigbuild
127+
rustup target add ${{ matrix.target }}
128+
cargo zigbuild --target ${{ matrix.target }} --release
129+
130+
# Set binary name to typeshare
131+
BINARY_NAME="typeshare"
132+
TARGET_DIR="target/${{ matrix.target }}/release"
133+
134+
# Create zip directory
135+
mkdir -p "dist"
136+
137+
# Create zip file with binary
138+
ZIP_NAME="${BINARY_NAME}-${{ github.ref_name }}-${{ matrix.target }}.zip"
139+
cd ${TARGET_DIR} && zip "../../../dist/${ZIP_NAME}" "${BINARY_NAME}${BINARY_SUFFIX}"
140+
cd ../../..
141+
142+
# Create manifest file similar to cargo-dist
143+
echo "{\"artifacts\": [{\"path\": \"dist/${ZIP_NAME}\"}]}" > dist-manifest.json
144+
145+
echo "Build complete, contents of dist-manifest.json:"
119146
cat dist-manifest.json
120-
121-
# Parse out what we just built and upload it to the Github Release™
147+
148+
# Upload to release
122149
cat dist-manifest.json | jq --raw-output ".artifacts[]?.path | select( . != null )" > uploads.txt
123150
echo "uploading..."
124151
cat uploads.txt

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ci = ["github"]
1313
installers = ["shell", "powershell"]
1414
# Target platforms to build apps for (Rust target-triple syntax)
1515
targets = [
16+
"aarch64-unknown-linux-gnu",
1617
"x86_64-unknown-linux-gnu",
1718
"x86_64-apple-darwin",
1819
"x86_64-pc-windows-msvc",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#[typeshare]
2+
struct DisallowedType {
3+
#[typeshare(typescript(type = "bigint"))]
4+
disallowed_type: u64,
5+
#[typeshare(typescript(type = "number"))]
6+
another_disallowed_type: i64,
7+
#[typeshare(typescript(type = "string"))]
8+
#[serde(with = "my_string_serde_impl")]
9+
disallowed_type_serde_with: u64,
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package proto
2+
3+
import "encoding/json"
4+
5+
type DisallowedType struct {
6+
DisallowedType uint64 `json:"disallowed_type"`
7+
AnotherDisallowedType int64 `json:"another_disallowed_type"`
8+
DisallowedTypeSerdeWith uint64 `json:"disallowed_type_serde_with"`
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.agilebits.onepassword
2+
3+
import kotlinx.serialization.Serializable
4+
import kotlinx.serialization.SerialName
5+
6+
@Serializable
7+
data class DisallowedType (
8+
val disallowed_type: ULong,
9+
val another_disallowed_type: Long,
10+
val disallowed_type_serde_with: ULong
11+
)
12+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.agilebits
2+
3+
package object onepassword {
4+
5+
type UByte = Byte
6+
type UShort = Short
7+
type UInt = Int
8+
type ULong = Int
9+
10+
}
11+
package onepassword {
12+
13+
case class DisallowedType (
14+
disallowed_type: ULong,
15+
another_disallowed_type: Long,
16+
disallowed_type_serde_with: ULong
17+
)
18+
19+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Foundation
2+
3+
public struct DisallowedType: Codable {
4+
public let disallowed_type: UInt64
5+
public let another_disallowed_type: Int64
6+
public let disallowed_type_serde_with: UInt64
7+
8+
public init(disallowed_type: UInt64, another_disallowed_type: Int64, disallowed_type_serde_with: UInt64) {
9+
self.disallowed_type = disallowed_type
10+
self.another_disallowed_type = another_disallowed_type
11+
self.disallowed_type_serde_with = disallowed_type_serde_with
12+
}
13+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export interface DisallowedType {
2+
disallowed_type: bigint;
3+
another_disallowed_type: number;
4+
disallowed_type_serde_with: string;
5+
}
6+

core/src/language/go.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ impl Language for Go {
148148
SpecialRustType::U32 => "uint32".into(),
149149
SpecialRustType::I54 | SpecialRustType::I64 => "int64".into(),
150150
SpecialRustType::U53 | SpecialRustType::U64 => "uint64".into(),
151+
SpecialRustType::U128 => "uint128".into(),
151152
SpecialRustType::Bool => "bool".into(),
152153
SpecialRustType::F32 => "float32".into(),
153154
SpecialRustType::F64 => "float64".into(),

core/src/language/kotlin.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ impl Language for Kotlin {
9090
SpecialRustType::Bool => "Boolean".into(),
9191
SpecialRustType::F32 => "Float".into(),
9292
SpecialRustType::F64 => "Double".into(),
93+
SpecialRustType::U128 => "BigInteger".into(),
9394
})
9495
}
9596

0 commit comments

Comments
 (0)