Skip to content

Commit

Permalink
finish build scrcpy on ios, add support libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
wsvn53 committed Jul 7, 2021
1 parent 84d67c2 commit 7f4371f
Show file tree
Hide file tree
Showing 9 changed files with 529 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Libs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include
lib
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
scrcpy-server:
curl -o scrcpy-server/scrcpy-server -L https://github.com/Genymobile/scrcpy/releases/download/v1.18/scrcpy-server-v1.18

libsdl:
OUTPUT=$$(pwd)/Libs ./Scripts/build-libsdl.sh

ffmpeg:
cd Libs && curl -O -L https://downloads.sourceforge.net/project/ffmpeg-ios/ffmpeg-ios-master.tar.bz2
cd Libs && bunzip2 ffmpeg-ios*.bz2
cd Libs && tar xvf ffmpeg-ios*.tar
cd Libs && cp -av FFmpeg-iOS/include/* include
cd Libs && cp -av FFmpeg-iOS/lib/* lib
cd Libs && rm -rf FFmpeg-iOS README.md ffmpeg-*

scrcpy-init: libsdl ffmpeg
# generate config.h
cd scrcpy-src && meson x --buildtype release --strip -Db_lto=true
# fix build issues
# 1. remove windows platform code
rm -v scrcpy-src/app/src/sys/win/process.c

.PHONY: scrcpy-server
421 changes: 421 additions & 0 deletions Scrcpy.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>libscrcpy.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
</dict>
</dict>
</plist>
24 changes: 24 additions & 0 deletions Scrcpy/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
5 changes: 5 additions & 0 deletions Scrcpy/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ @implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
[self setupViews];
}

- (void)setupViews {
self.title = @"Scrcpy";
self.view.backgroundColor = UIColor.whiteColor;
}

@end
9 changes: 9 additions & 0 deletions Scrcpy/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
//

#import <UIKit/UIKit.h>
#import "config.h"
#import <SDL2/SDL_main.h>
#import "ViewController.h"

int main(int argc, char * argv[]) {
NSLog(@"Hello scrcpy v%s", SCRCPY_VERSION);

static UIWindow *window = nil;
window = [[UIWindow alloc] init];
window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[ViewController new]];
[window makeKeyAndVisible];

return 0;
}
24 changes: 24 additions & 0 deletions Scripts/build-libsdl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -x;

BUILD_DIR=$(mktemp -d -t SDL);
cd $BUILD_DIR;

curl -O https://www.libsdl.org/release/SDL2-2.0.14.tar.gz;
tar xzvf SDL*.tar.gz;

xcodebuild clean build BUILD_DIR=$BUILD_DIR/build ARCHS="arm64" CONFIGURATION=Release -project SDL2-*/Xcode/SDL/SDL.xcodeproj -scheme "Static Library-iOS" -sdk iphoneos;
xcodebuild clean build BUILD_DIR=$BUILD_DIR/build ARCHS="x86_64" CONFIGURATION=Release -project SDL2-*/Xcode/SDL/SDL.xcodeproj -scheme "Static Library-iOS" -sdk iphonesimulator;

lipo -create build/*/libSDL2.a -output build/libSDL2.a;
file build/libSDL2.a;

[[ -d "$OUTPUT/lib" ]] || mkdir -pv "$OUTPUT/lib";
[[ -d "$OUTPUT/include/SDL2" ]] || mkdir -pv $OUTPUT/include/SDL2;
[[ -d "$OUTPUT" ]] && {
[[ -d "$OUTPUT/lib" ]] && cp -v build/libSDL2.a $OUTPUT/lib;
[[ -d "$OUTPUT/include" ]] && cp -v SDL2-*/include/*.h $OUTPUT/include/SDL2;
}

[[ -d "$BUILD_DIR" ]] && rm -rf $BUILD_DIR;
21 changes: 21 additions & 0 deletions libscrcpy/PrefixHeader.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// PrefixHeader.pch
// Scrcpy
//
// Created by Ethan on 2021/7/7.
//

#ifndef PrefixHeader_pch
#define PrefixHeader_pch

#include <OpenGLES/gltypes.h>
#include <OpenGLES/ES3/gl.h>

typedef GLfloat GLdouble;
typedef double GLclampd;

#include <SDL2/SDL_opengl_glext.h>

#define main scrcpy_main

#endif /* PrefixHeader_pch */

0 comments on commit 7f4371f

Please sign in to comment.