Skip to content

Commit

Permalink
add build script for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
B0ney committed Oct 17, 2023
1 parent c67d3f2 commit 2842a09
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/build_gui_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ jobs:
- target: linux
os: ubuntu-latest
make: bash dist/build-linux.sh package
# artifact_path: |
# echo "ARTIFACT_PATH=$(bash dist/build-linux.sh artifact_path)/*" >> "$GITHUB_ENV"


- target: windows
os: windows-latest
make: powershell dist/build-windows.ps1

# - target: macos
# os: macos-latest
# make: bash dist/build-macos.sh
# artifact_path: |
# echo "ARTIFACT_PATH=target/release/macos/xmodits.dmg" >> "$GITHUB_ENV"

runs-on: ${{ matrix.target.os }}

Expand Down
35 changes: 35 additions & 0 deletions dist/build-windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

$ARCH="x86_64"
$PLATFORM="windows"

$FEATURES="build_info"

$ARCHIVE_DIR="$RELEASE_DIR/archive"
$ARTIFACT_DIR="$RELEASE_DIR/artifact"


# Compile application with features
cargo build -p xmodits-gui --release --features=$FEATURES

# Create artifact folder
mkdir -Force -p "target/release/artifact"

# Create archive folder
mkdir -Force -p "target/release/archive"

# move and rename xmodits-gui.exe to xmodits in archive folder
mv -Force "target/release/xmodits-gui.exe" "target/release/archive/xmodits.exe"

# Copy extras to archive folder
cp -Force "README.md" "target/release/archive/"
cp -Force "LICENSE" "target/release/archive/"

# Get version number
$VERSION = target/release/xmodits.exe --version | Out-String
$VERSION = $VERSION.Trim() # trim whitespace, includes \n

# Compress archive contents of archive folder to a zip file
$ARTIFACT_PATH = "target/release/artifact/xmodits-gui-$VERSION-$PLATFORM-$ARCH.zip"
Compress-Archive -Force -Path "target/release/archive/*" -DestinationPath $ARTIFACT_PATH

echo "Packaged archive: $ARTIFACT_PATH"
3 changes: 0 additions & 3 deletions src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ pub fn init_logging() {
use tracing::Level;
use tracing_subscriber::FmtSubscriber;

#[cfg(windows)]
reattach_windows_terminal();

// all spans/events with a level higher than TRACE (e.g, debug, info, warn, etc.)
// will be written to stdout.
set_global_default(
Expand Down
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ use tikv_jemallocator::Jemalloc;
static GLOBAL: Jemalloc = Jemalloc;

fn main() -> iced::Result {
#[cfg(windows)]
logger::reattach_windows_terminal();

let args = env::args().skip(1);

let version = args
Expand Down

0 comments on commit 2842a09

Please sign in to comment.