portable-service: add quick_start feature and ci
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
		
							parent
							
								
									0a2627f06a
								
							
						
					
					
						commit
						0199770454
					
				
							
								
								
									
										9
									
								
								.github/workflows/flutter-nightly.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								.github/workflows/flutter-nightly.yml
									
									
									
									
										vendored
									
									
								
							| @ -15,7 +15,7 @@ env: | |||||||
| 
 | 
 | ||||||
| jobs: | jobs: | ||||||
|   build-for-windows: |   build-for-windows: | ||||||
|     name: ${{ matrix.job.target }} (${{ matrix.job.os }}) |     name: ${{ matrix.job.target }} (${{ matrix.job.os }}) ${{ matrix.job.suffix }} | ||||||
|     runs-on: ${{ matrix.job.os }} |     runs-on: ${{ matrix.job.os }} | ||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
| @ -23,7 +23,8 @@ jobs: | |||||||
|         job: |         job: | ||||||
|           # - { target: i686-pc-windows-msvc        , os: windows-2019                  } |           # - { target: i686-pc-windows-msvc        , os: windows-2019                  } | ||||||
|           # - { target: x86_64-pc-windows-gnu       , os: windows-2019                  } |           # - { target: x86_64-pc-windows-gnu       , os: windows-2019                  } | ||||||
|           - { target: x86_64-pc-windows-msvc      , os: windows-2019 } |           - { target: x86_64-pc-windows-msvc      , os: windows-2019, suffix: ""   , extra-build-args: ""             } | ||||||
|  |           - { target: x86_64-pc-windows-msvc      , os: windows-2019, suffix: "-qs", extra-build-args: "--quick_start" } | ||||||
|     steps: |     steps: | ||||||
|       - name: Checkout source code |       - name: Checkout source code | ||||||
|         uses: actions/checkout@v3 |         uses: actions/checkout@v3 | ||||||
| @ -83,13 +84,13 @@ jobs: | |||||||
|         shell: bash |         shell: bash | ||||||
| 
 | 
 | ||||||
|       - name: Build rustdesk |       - name: Build rustdesk | ||||||
|         run: python3 .\build.py --portable --hwcodec --flutter |         run: python3 .\build.py --portable --hwcodec --flutter ${{ matrix.job.extra-build-args }} | ||||||
| 
 | 
 | ||||||
|       - name: Rename rustdesk |       - name: Rename rustdesk | ||||||
|         shell: bash |         shell: bash | ||||||
|         run: | |         run: | | ||||||
|           for name in rustdesk*??-install.exe; do |           for name in rustdesk*??-install.exe; do | ||||||
|               mv "$name" "${name%%-install.exe}-${{ matrix.job.target }}.exe" |               mv "$name" "${name%%-install.exe}-${{ matrix.job.target }}${{ matrix.job.suffix }}.exe" | ||||||
|           done |           done | ||||||
| 
 | 
 | ||||||
|       - name: Publish Release |       - name: Publish Release | ||||||
|  | |||||||
| @ -29,6 +29,7 @@ flutter = ["flutter_rust_bridge"] | |||||||
| default = ["use_dasp"] | default = ["use_dasp"] | ||||||
| hwcodec = ["scrap/hwcodec"] | hwcodec = ["scrap/hwcodec"] | ||||||
| mediacodec = ["scrap/mediacodec"] | mediacodec = ["scrap/mediacodec"] | ||||||
|  | quick_start = [] | ||||||
| 
 | 
 | ||||||
| # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										7
									
								
								build.py
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								build.py
									
									
									
									
									
								
							| @ -81,6 +81,11 @@ def make_parser(): | |||||||
|         action='store_true', |         action='store_true', | ||||||
|         help='Build windows portable' |         help='Build windows portable' | ||||||
|     ) |     ) | ||||||
|  |     parser.add_argument( | ||||||
|  |         '--quick_start', | ||||||
|  |         action='store_true', | ||||||
|  |         help='Windows quick start portable' | ||||||
|  |     ) | ||||||
|     parser.add_argument( |     parser.add_argument( | ||||||
|         '--flatpak', |         '--flatpak', | ||||||
|         action='store_true', |         action='store_true', | ||||||
| @ -189,6 +194,8 @@ def get_features(args): | |||||||
|     features = ['inline'] |     features = ['inline'] | ||||||
|     if windows: |     if windows: | ||||||
|         features.extend(get_rc_features(args)) |         features.extend(get_rc_features(args)) | ||||||
|  |         if args.quick_start: | ||||||
|  |             features.append('quick_start') | ||||||
|     if args.hwcodec: |     if args.hwcodec: | ||||||
|         features.append('hwcodec') |         features.append('hwcodec') | ||||||
|     if args.flutter: |     if args.flutter: | ||||||
|  | |||||||
| @ -81,6 +81,13 @@ pub fn core_main() -> Option<Vec<String>> { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     #[cfg(windows)] |     #[cfg(windows)] | ||||||
|  |     #[cfg(feature = "quick_start")] | ||||||
|  |     if !crate::platform::is_installed() && args.is_empty() && !_is_elevate && !_is_run_as_system { | ||||||
|  |         if let Err(e) = crate::portable_service::client::start_portable_service() { | ||||||
|  |             log::error!("Failed to start portable service:{:?}", e); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     #[cfg(windows)] | ||||||
|     if !crate::platform::is_installed() && (_is_elevate || _is_run_as_system) { |     if !crate::platform::is_installed() && (_is_elevate || _is_run_as_system) { | ||||||
|         crate::platform::elevate_or_run_as_system(click_setup, _is_elevate, _is_run_as_system); |         crate::platform::elevate_or_run_as_system(click_setup, _is_elevate, _is_run_as_system); | ||||||
|         return None; |         return None; | ||||||
| @ -276,7 +283,7 @@ fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<Strin | |||||||
|             "RustDesk", |             "RustDesk", | ||||||
|             (WM_USER + 2) as _, // refered from unilinks desktop pub
 |             (WM_USER + 2) as _, // refered from unilinks desktop pub
 | ||||||
|             uni_links.as_str(), |             uni_links.as_str(), | ||||||
|             true |             true, | ||||||
|         ); |         ); | ||||||
|         return if res { None } else { Some(Vec::new()) }; |         return if res { None } else { Some(Vec::new()) }; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1553,6 +1553,13 @@ pub fn run_as_system(arg: &str) -> ResultType<()> { | |||||||
| 
 | 
 | ||||||
| pub fn elevate_or_run_as_system(is_setup: bool, is_elevate: bool, is_run_as_system: bool) { | pub fn elevate_or_run_as_system(is_setup: bool, is_elevate: bool, is_run_as_system: bool) { | ||||||
|     // avoid possible run recursively due to failed run.
 |     // avoid possible run recursively due to failed run.
 | ||||||
|  |     log::info!( | ||||||
|  |         "elevate:{}->{:?}, run_as_system:{}->{}", | ||||||
|  |         is_elevate, | ||||||
|  |         is_elevated(None), | ||||||
|  |         is_run_as_system, | ||||||
|  |         crate::username(), | ||||||
|  |     ); | ||||||
|     let arg_elevate = if is_setup { |     let arg_elevate = if is_setup { | ||||||
|         "--noinstall --elevate" |         "--noinstall --elevate" | ||||||
|     } else { |     } else { | ||||||
|  | |||||||
| @ -406,8 +406,9 @@ pub mod server { | |||||||
|                                     Pong => { |                                     Pong => { | ||||||
|                                         nack = 0; |                                         nack = 0; | ||||||
|                                     } |                                     } | ||||||
|                                     ConnCount(Some(n)) => { |                                     ConnCount(Some(_n)) => { | ||||||
|                                         if n == 0 { |                                         #[cfg(not(feature = "quick_start"))] | ||||||
|  |                                         if _n == 0 { | ||||||
|                                             log::info!("Connnection count equals 0, exit"); |                                             log::info!("Connnection count equals 0, exit"); | ||||||
|                                             stream.send(&Data::DataPortableService(WillClose)).await.ok(); |                                             stream.send(&Data::DataPortableService(WillClose)).await.ok(); | ||||||
|                                             break; |                                             break; | ||||||
| @ -435,6 +436,7 @@ pub mod server { | |||||||
|                                 break; |                                 break; | ||||||
|                             } |                             } | ||||||
|                             stream.send(&Data::DataPortableService(Ping)).await.ok(); |                             stream.send(&Data::DataPortableService(Ping)).await.ok(); | ||||||
|  |                             #[cfg(not(feature = "quick_start"))] | ||||||
|                             stream.send(&Data::DataPortableService(ConnCount(None))).await.ok(); |                             stream.send(&Data::DataPortableService(ConnCount(None))).await.ok(); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
| @ -462,6 +464,7 @@ pub mod client { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pub(crate) fn start_portable_service() -> ResultType<()> { |     pub(crate) fn start_portable_service() -> ResultType<()> { | ||||||
|  |         log::info!("start portable service"); | ||||||
|         if PORTABLE_SERVICE_RUNNING.lock().unwrap().clone() { |         if PORTABLE_SERVICE_RUNNING.lock().unwrap().clone() { | ||||||
|             bail!("already running"); |             bail!("already running"); | ||||||
|         } |         } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user