Skip to content

Instantly share code, notes, and snippets.

@zzeroo
Created November 17, 2020 19:05
Show Gist options
  • Save zzeroo/332ed0e493c34230c7415b07fa1de418 to your computer and use it in GitHub Desktop.
Save zzeroo/332ed0e493c34230c7415b07fa1de418 to your computer and use it in GitHub Desktop.
Helper .nsi script to extract information from Rust's Cargo.toml
; CargoAttributes.nsi
;
; * Copyright © 2020 Stefan Müller <co@zzeroo.com>
; *
; * SPDX-License-Identifier: GPL-2.0-or-later
;
; Helper .nsi script to extract information from Rust's Cargo.toml.
;
; # Usage
;
; Put this file aside your nsi script and add the following to your main script:
;
; !makensis "CargoAttributes.nsi"
; !system "CargoAttributes.exe"
; !system "CargoAttributes.sh"
; !include "CargoAttributes.txt"
; ; optional cleanup
; !delfile "CargoAttributes.exe"
; !delfile "CargoAttributes.sh"
; !delfile "CargoAttributes.txt"
!include "TextFunc.nsh"
Unicode true
OutFile CargoAttributes.exe
SilentInstall silent
RequestExecutionLevel user
Section
${ConfigRead} Cargo.toml "name =" $R1
${ConfigRead} Cargo.toml "version =" $R2
## Write it to a !define for use in main script
FileOpen $R0 "$EXEDIR\CargoAttributes.txt" w
FileWrite $R0 '!define CARGO_PKG_NAME $R1$\r$\n'
FileWrite $R0 '!define CARGO_PKG_VERSION $R2'
FileClose $R0
SectionEnd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment