build: Fix release
This commit is contained in:
		
							
								
								
									
										49
									
								
								cargo_build.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								cargo_build.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,49 @@
 | 
			
		||||
#!/usr/bin/env python3
 | 
			
		||||
 | 
			
		||||
"""This script manages Cargo builds
 | 
			
		||||
while keeping the artifact directory within the build tree
 | 
			
		||||
instead of the source tree.
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
import shlex
 | 
			
		||||
import subprocess
 | 
			
		||||
import sys
 | 
			
		||||
 | 
			
		||||
source_dir = Path(__file__).absolute().parent
 | 
			
		||||
 | 
			
		||||
args = sys.argv[1:]
 | 
			
		||||
binary_dir = "debug"
 | 
			
		||||
 | 
			
		||||
if '--release' in args:
 | 
			
		||||
    binary_dir = "release"
 | 
			
		||||
 | 
			
		||||
# The file produced by Cargo will have a special name
 | 
			
		||||
try:
 | 
			
		||||
    i = args.index('--rename')
 | 
			
		||||
except ValueError:
 | 
			
		||||
    filename = None
 | 
			
		||||
else:
 | 
			
		||||
    args.pop(i)
 | 
			
		||||
    filename = args.pop(i)
 | 
			
		||||
 | 
			
		||||
# The target destination of the produced file is a positional argument
 | 
			
		||||
out_path = [arg for arg in args if not arg.startswith('--')]
 | 
			
		||||
if out_path:
 | 
			
		||||
    out_path = out_path[0]
 | 
			
		||||
    i = args.index(out_path)
 | 
			
		||||
    args.pop(i)    
 | 
			
		||||
 | 
			
		||||
subprocess.run(['sh', "{}/cargo.sh".format(shlex.quote(source_dir.as_posix())), 'build']
 | 
			
		||||
    + args,
 | 
			
		||||
    check=True)
 | 
			
		||||
 | 
			
		||||
if out_path:
 | 
			
		||||
    out_path = Path(out_path).absolute()
 | 
			
		||||
    out_basename = out_path.name
 | 
			
		||||
    filename = filename or out_basename
 | 
			
		||||
    subprocess.run(['cp', '-a',
 | 
			
		||||
        './{}/{}'.format(shlex.quote(binary_dir), shlex.quote(filename)),
 | 
			
		||||
        out_path],
 | 
			
		||||
        check=True)
 | 
			
		||||
 | 
			
		||||
@ -1,34 +0,0 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
# This script manages Cargo builds
 | 
			
		||||
# while keeping the artifact directory within the build tree
 | 
			
		||||
# instead of the source tree
 | 
			
		||||
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
SCRIPT_PATH="$(realpath "$0")"
 | 
			
		||||
SOURCE_DIR="$(dirname "$SCRIPT_PATH")"
 | 
			
		||||
 | 
			
		||||
RELEASE=""
 | 
			
		||||
BINARY_DIR="debug"
 | 
			
		||||
if [ "${1}" = "--release" ]; then
 | 
			
		||||
    shift
 | 
			
		||||
    BINARY_DIR="release"
 | 
			
		||||
    RELEASE="--release"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ "${1}" = "--rename" ]; then
 | 
			
		||||
    shift
 | 
			
		||||
    FILENAME="${1}"
 | 
			
		||||
    shift
 | 
			
		||||
fi
 | 
			
		||||
OUT_PATH="$(realpath "${1}")"
 | 
			
		||||
shift
 | 
			
		||||
OUT_BASENAME="$(basename "${OUT_PATH}")"
 | 
			
		||||
FILENAME="${FILENAME:-"${OUT_BASENAME}"}"
 | 
			
		||||
 | 
			
		||||
sh "$SOURCE_DIR"/cargo.sh build $RELEASE "$@"
 | 
			
		||||
 | 
			
		||||
if [ -n "${OUT_PATH}" ]; then
 | 
			
		||||
    cp -a ./"${BINARY_DIR}"/"${FILENAME}" "${OUT_PATH}"
 | 
			
		||||
fi
 | 
			
		||||
							
								
								
									
										1
									
								
								debian/control
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								debian/control
									
									
									
									
										vendored
									
									
								
							@ -26,6 +26,7 @@ Build-Depends:
 | 
			
		||||
 librust-xkbcommon-0.4+wayland-dev (>= 0.4),
 | 
			
		||||
 libwayland-dev (>= 1.16),
 | 
			
		||||
 lsb-release,
 | 
			
		||||
 python3,
 | 
			
		||||
 rustc,
 | 
			
		||||
 wayland-protocols (>= 1.14),
 | 
			
		||||
Standards-Version: 4.1.3
 | 
			
		||||
 | 
			
		||||
@ -100,7 +100,7 @@ cargo_toml = custom_target(
 | 
			
		||||
 | 
			
		||||
dep_cargo = find_program('cargo')
 | 
			
		||||
cargo_script = find_program('cargo.sh')
 | 
			
		||||
cargo_build = find_program('cargo_build.sh')
 | 
			
		||||
cargo_build = find_program('cargo_build.py')
 | 
			
		||||
 | 
			
		||||
subdir('data')
 | 
			
		||||
subdir('protocols')
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user