-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to latest mach zig + misc improvements
- Loading branch information
Showing
9 changed files
with
129 additions
and
106 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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
zig-out/ | ||
zig-cache/ | ||
.zig-cache/ | ||
fresh_presence_config.ini |
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 |
---|---|---|
|
@@ -2,17 +2,20 @@ | |
|
||
This document details the steps and other important information on how to contribute to FreshPresence. Feel free to skip sections if you believe you're already set. | ||
|
||
## Requirements: | ||
## Requirements | ||
|
||
- Basic knowledge of [Zig](https://ziglang.org/) | ||
- Basic knowledge of the Discord RPC API | ||
|
||
## Software prerequisites | ||
|
||
- [Zig](https://ziglang.org) (We target the latest [Mach Nominated Zig Version](https://machengine.org/about/nominated-zig)) | ||
- [Git](https://git-scm.com) | ||
- Any text editor | ||
|
||
# Preparing your system | ||
In order to use Git you must set up your configuration, this should ideally match your GitHub account's name and email. | ||
## Preparing your system | ||
|
||
In order to use Git you must set up your configuration, this should ideally match your GitHub account's name and email. | ||
|
||
You can use [GitHub Desktop](https://desktop.github.com) or the IDE of your choice to help you with this! **Or if you're more technically inclined**, follow the CLI instructions below. | ||
|
||
|
@@ -22,23 +25,22 @@ This will modify the **global** config, which will allow you to contribute to mu | |
|
||
`$ git config --global user.email [email protected]` | ||
|
||
# Preparing your new development environment | ||
## Preparing your new development environment | ||
|
||
It's almost time to clone FreshPresence! Create a fork by pressing the "Fork" button at the base of this repository. | ||
|
||
Afterwards, open a terminal to your working directory and clone the new fork using Git. | ||
|
||
This is usually done with the following command: | ||
`$ git@github.com:<YOUR_USERNAME>/FreshPresence.git` | ||
This is usually done with the following command: | ||
`$ git clone https://github.com/<YOUR_USERNAME>/FreshPresence` | ||
|
||
Now, open the folder/workspace/solution with the IDE you chose. Explore the codebase, experiment, and have fun! | ||
|
||
To run the software in **DEBUG** mode, simply write: | ||
To run the software in **Debug** mode, simply write: | ||
`$ zig build run` | ||
|
||
To compile for a specific platform, you can append `-Dtarget=TARGET` to the build invocation, eg. `zig build -Dtarget=x86_64-linux` | ||
To compile for a specific platform, you can append `-Dtarget=TARGET` to the build invocation, eg. `zig build -Dtarget=x86_64-linux-gnu` | ||
|
||
To compile a release build, you can append `-Doptimize=ReleaseSmall`. the possible options are `Debug`, `ReleaseSmall`, `ReleaseFast`, `ReleaseSafe`. Our builds are compiled with ReleaseSmall, but for test builds Debug or ReleaseSafe are preferred! | ||
|
||
Make sure to add [the upstream FreshPresence repository](https://github.com/LittleBigRefresh/FreshPresence) as the "**upstream**" remote using your IDE or GitHub Desktop. Happy hunting! | ||
|
||
### Follow up in the patching documentation for connecting using your choice of device, TBW |
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
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
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
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
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 |
---|---|---|
@@ -1,17 +1,13 @@ | ||
const std = @import("std"); | ||
|
||
pub fn qualifyAsset(allocator: std.mem.Allocator, uri: std.Uri, asset: []const u8, use_application_asset: bool) ![]const u8 { | ||
var qualified_asset = std.ArrayList(u8).init(allocator); | ||
|
||
pub fn qualifyAsset(writer: anytype, uri: std.Uri, asset: []const u8, use_application_asset: bool) !void { | ||
//If the asset length matches a SHA1 hex string, | ||
if (!use_application_asset) { | ||
//Assume it is a server asset | ||
try uri.format(":+", .{}, qualified_asset.writer()); | ||
try std.fmt.format(qualified_asset.writer(), "/api/v3/assets/{s}/image", .{asset}); | ||
try uri.format(";+", .{}, writer); | ||
try std.fmt.format(writer, "/api/v3/assets/{s}/image", .{asset}); | ||
} else { | ||
//Assume it is a discord asset | ||
try qualified_asset.appendSlice(asset); | ||
try writer.writeAll(asset); | ||
} | ||
|
||
return try qualified_asset.toOwnedSlice(); | ||
} |
Oops, something went wrong.