Merge pull request #1021 from 21pages/hwcodec

hwcodec: update build.py
This commit is contained in:
RustDesk 2022-07-22 10:40:18 +08:00 committed by GitHub
commit 07107ad034
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 15 deletions

32
build.py Normal file → Executable file
View File

@ -22,7 +22,7 @@ def get_version():
return '' return ''
def get_features(feature): def prase_rc_features(feature):
available_features = { available_features = {
'IddDriver': { 'IddDriver': {
'zip_url': 'https://github.com/fufesou/RustDeskIddDriver/releases/download/v0.1/RustDeskIddDriver_x64.zip', 'zip_url': 'https://github.com/fufesou/RustDeskIddDriver/releases/download/v0.1/RustDeskIddDriver_x64.zip',
@ -94,8 +94,8 @@ def download_extract_features(features, res_dir):
print(f'{feat} extract end') print(f'{feat} extract end')
def build_windows(args): def get_rc_features(args):
features = get_features(args.feature) features = prase_rc_features(args.feature)
if features: if features:
print(f'Build with features {list(features.keys())}') print(f'Build with features {list(features.keys())}')
res_dir = 'resources' res_dir = 'resources'
@ -105,12 +105,17 @@ def build_windows(args):
raise Exception(f'Find file {res_dir}, not a directory') raise Exception(f'Find file {res_dir}, not a directory')
os.makedirs(res_dir, exist_ok=True) os.makedirs(res_dir, exist_ok=True)
download_extract_features(features, res_dir) download_extract_features(features, res_dir)
return ['with_rc'] if features else []
with_rc = ',with_rc' if features else ''
hwcodec = ',hwcodec' if args.hwcodec else '' def get_features(args):
cmd = 'cargo build --release --features inline' + with_rc + hwcodec features = ['inline']
print(cmd) if windows:
os.system(cmd) features.extend(get_rc_features(args))
if args.hwcodec:
features.append('hwcodec')
print("features:", features)
return features
def main(): def main():
parser = make_parser() parser = make_parser()
@ -129,8 +134,9 @@ def main():
if os.path.isfile('/usr/bin/pacman'): if os.path.isfile('/usr/bin/pacman'):
os.system('git checkout src/ui/common.tis') os.system('git checkout src/ui/common.tis')
version = get_version() version = get_version()
features = ",".join(get_features(args))
if windows: if windows:
build_windows(args) os.system('cargo build --release --features ' + features)
# os.system('upx.exe target/release/rustdesk.exe') # os.system('upx.exe target/release/rustdesk.exe')
os.system('mv target/release/rustdesk.exe target/release/RustDesk.exe') os.system('mv target/release/rustdesk.exe target/release/RustDesk.exe')
pa = os.environ.get('P') pa = os.environ.get('P')
@ -141,7 +147,7 @@ def main():
print('Not signed') print('Not signed')
os.system(f'cp -rf target/release/RustDesk.exe rustdesk-{version}-setdown.exe') os.system(f'cp -rf target/release/RustDesk.exe rustdesk-{version}-setdown.exe')
elif os.path.isfile('/usr/bin/pacman'): elif os.path.isfile('/usr/bin/pacman'):
os.system('cargo build --release --features inline') os.system('cargo build --release --features ' + features)
os.system('git checkout src/ui/common.tis') os.system('git checkout src/ui/common.tis')
os.system('strip target/release/rustdesk') os.system('strip target/release/rustdesk')
os.system("sed -i 's/pkgver=.*/pkgver=%s/g' PKGBUILD" % version) os.system("sed -i 's/pkgver=.*/pkgver=%s/g' PKGBUILD" % version)
@ -150,7 +156,7 @@ def main():
os.system('mv rustdesk-%s-0-x86_64.pkg.tar.zst rustdesk-%s-manjaro-arch.pkg.tar.zst' % (version, version)) os.system('mv rustdesk-%s-0-x86_64.pkg.tar.zst rustdesk-%s-manjaro-arch.pkg.tar.zst' % (version, version))
# pacman -U ./rustdesk.pkg.tar.zst # pacman -U ./rustdesk.pkg.tar.zst
elif os.path.isfile('/usr/bin/yum'): elif os.path.isfile('/usr/bin/yum'):
os.system('cargo build --release --features inline') os.system('cargo build --release --features ' + features)
os.system('strip target/release/rustdesk') os.system('strip target/release/rustdesk')
os.system("sed -i 's/Version: .*/Version: %s/g' rpm.spec" % version) os.system("sed -i 's/Version: .*/Version: %s/g' rpm.spec" % version)
os.system('HBB=`pwd` rpmbuild -ba rpm.spec') os.system('HBB=`pwd` rpmbuild -ba rpm.spec')
@ -158,14 +164,14 @@ def main():
version, version)) version, version))
# yum localinstall rustdesk.rpm # yum localinstall rustdesk.rpm
elif os.path.isfile('/usr/bin/zypper'): elif os.path.isfile('/usr/bin/zypper'):
os.system('cargo build --release --features inline') os.system('cargo build --release --features ' + features)
os.system('strip target/release/rustdesk') os.system('strip target/release/rustdesk')
os.system("sed -i 's/Version: .*/Version: %s/g' rpm-suse.spec" % version) os.system("sed -i 's/Version: .*/Version: %s/g' rpm-suse.spec" % version)
os.system('HBB=`pwd` rpmbuild -ba rpm-suse.spec') os.system('HBB=`pwd` rpmbuild -ba rpm-suse.spec')
os.system('mv $HOME/rpmbuild/RPMS/x86_64/rustdesk-%s-0.x86_64.rpm ./rustdesk-%s-suse.rpm' % (version, version)) os.system('mv $HOME/rpmbuild/RPMS/x86_64/rustdesk-%s-0.x86_64.rpm ./rustdesk-%s-suse.rpm' % (version, version))
# yum localinstall rustdesk.rpm # yum localinstall rustdesk.rpm
else: else:
os.system('cargo bundle --release --features inline') os.system('cargo bundle --release --features ' + features)
if osx: if osx:
os.system( os.system(
'strip target/release/bundle/osx/RustDesk.app/Contents/MacOS/rustdesk') 'strip target/release/bundle/osx/RustDesk.app/Contents/MacOS/rustdesk')

View File

@ -7,7 +7,7 @@ use hbb_common::{
config::HwCodecConfig, config::HwCodecConfig,
lazy_static, log, lazy_static, log,
message_proto::{EncodedVideoFrame, EncodedVideoFrames, Message, VideoFrame}, message_proto::{EncodedVideoFrame, EncodedVideoFrames, Message, VideoFrame},
ResultType, ResultType, bytes::Bytes,
}; };
use hwcodec::{ use hwcodec::{
decode::{DecodeContext, DecodeFrame, Decoder}, decode::{DecodeContext, DecodeFrame, Decoder},
@ -91,7 +91,7 @@ impl EncoderApi for HwEncoder {
let mut frames = Vec::new(); let mut frames = Vec::new();
for frame in self.encode(frame).with_context(|| "Failed to encode")? { for frame in self.encode(frame).with_context(|| "Failed to encode")? {
frames.push(EncodedVideoFrame { frames.push(EncodedVideoFrame {
data: frame.data, data: Bytes::from(frame.data),
pts: frame.pts as _, pts: frame.pts as _,
..Default::default() ..Default::default()
}); });