Skip to content

Commit

Permalink
windows: Print command being run to make build errors clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Aug 9, 2024
1 parent 3576ebb commit 991afe9
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions windows/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,18 @@ def find_depends(exe):
mingw_dir = m.group(1)
return mingw_dir, dlls

fn check_call(args):
print(f"RUN {shlex.join(args)}")
try:
subprocess.check_call(args)
except subprocess.CalledProcessError as e:
println(f"ERROR: {args[0]} failed with code {e.returncode}")

# Build application with rustup
cmd = CARGO + ['build']
if args.release:
cmd.append('--release')
subprocess.check_call(cmd)
check_call(cmd)

# Generate set of all required dlls
dlls = set()
Expand Down Expand Up @@ -108,7 +114,7 @@ def strip(srcdir, destdir, path):
dest = f"{destdir}/{path}"
os.makedirs(os.path.dirname(dest), exist_ok=True)
print(f"Strip {src} -> {dest}")
subprocess.check_call([f"strip.exe", '-o', dest, src])
check_call([f"strip.exe", '-o', dest, src])

# Copy executables and libraries
if os.path.exists('out'):
Expand All @@ -125,7 +131,7 @@ def strip(srcdir, destdir, path):
# Copy additional data
for i in ADDITIONAL_FILES:
copy(mingw_dir, 'out', i)
subprocess.check_call(["glib-compile-schemas", "out/share/glib-2.0/schemas"])
check_call(["glib-compile-schemas", "out/share/glib-2.0/schemas"])

# Extract crate version from cargo
meta_str = subprocess.check_output(CARGO + ["metadata", "--format-version", "1", "--no-deps"])
Expand All @@ -134,12 +140,12 @@ def strip(srcdir, destdir, path):
crate_version = package['version']

# Generate Icon and installer banner
subprocess.check_call(["rsvg-convert", "--width", "256", "--height", "256", "-o", "keyboard-configurator.png", ICON])
subprocess.check_call([CONVERT, "keyboard-configurator.png", "out/keyboard-configurator.ico"])
subprocess.check_call(["rsvg-convert", "--width", "493", "--height", "58", "-o", "banner.png", "banner.svg"])
subprocess.check_call([CONVERT, "banner.png", "banner.bmp"])
subprocess.check_call(["rsvg-convert", "--width", "493", "--height", "312", "-o", "dialog.png", "dialog.svg"])
subprocess.check_call([CONVERT, "dialog.png", "dialog.bmp"])
check_call(["rsvg-convert", "--width", "256", "--height", "256", "-o", "keyboard-configurator.png", ICON])
check_call([CONVERT, "keyboard-configurator.png", "out/keyboard-configurator.ico"])
check_call(["rsvg-convert", "--width", "493", "--height", "58", "-o", "banner.png", "banner.svg"])
check_call([CONVERT, "banner.png", "banner.bmp"])
check_call(["rsvg-convert", "--width", "493", "--height", "312", "-o", "dialog.png", "dialog.svg"])
check_call([CONVERT, "dialog.png", "dialog.bmp"])

# Generate libraries.wxi
with open('libraries.wxi', 'w') as f:
Expand Down Expand Up @@ -170,8 +176,8 @@ def add_files(dirpath, indent):
f.write('</Include>\n')

# Build .msi
subprocess.check_call([f"{wix_dir}/bin/candle.exe", ".\keyboard-configurator.wxs", f"-dcrate_version={crate_version}"])
subprocess.check_call([f"{wix_dir}/bin/light.exe", "-ext", "WixUIExtension", ".\keyboard-configurator.wixobj"])
check_call([f"{wix_dir}/bin/candle.exe", ".\keyboard-configurator.wxs", f"-dcrate_version={crate_version}"])
check_call([f"{wix_dir}/bin/light.exe", "-ext", "WixUIExtension", ".\keyboard-configurator.wixobj"])

if args.sign:
if not os.path.isdir('sign'):
Expand All @@ -197,7 +203,7 @@ def add_files(dirpath, indent):
os.rename(tool_dir + ".partial", tool_dir)

# Sign with specified cloud signing key
subprocess.check_call([
check_call([
"cmd", "/c", "CodeSignTool.bat",
"sign",
"-credential_id=" + os.environ["SSL_COM_CREDENTIAL_ID"],
Expand Down

0 comments on commit 991afe9

Please sign in to comment.