Commit 95570520 authored by nanahira's avatar nanahira

some patches for generated libs

parent 3ee6435f
......@@ -67,3 +67,6 @@ Assets/StreamingAssets/update.zip*
commamd.shell
/output
/Classes
/Libraries
/URLUtility.o
......@@ -3,13 +3,8 @@
set UNITY_PATH="C:\Program Files\Unity\Editor\Unity.exe"
mkdir output
mkdir KoishiPro2-src
%UNITY_PATH% -batchmode -nographics -silent-crashes -projectPath %cd% -logFile KoishiPro2-src/build.log -executeMethod BuildHelper.Build -quit
mkdir dist
%UNITY_PATH% -batchmode -nographics -silent-crashes -projectPath %cd% -logFile dist/build.log -executeMethod BuildHelper.Build -quit
if %errorlevel% neq 0 exit /b %errorlevel%
cat KoishiPro2-src/build.log
bash -c "sed -i '/>UIStatusBarStyle</i\ <key>UIFileSharingEnabled</key>\n <true />\n <key>LSSupportsOpeningDocumentsInPlace</key>\n <true />' output/Info.plist"
cd output
7z a -mx9 ../KoishiPro2-src/KoishiPro2-src.7z *
cd ..
cat dist/build.log
mv output dist/src
stages:
- build
- patch
- deploy
variables:
......@@ -15,22 +16,61 @@ unity:
script: cmd /C .gitlab-ci.bat
artifacts:
paths:
- KoishiPro2-src/
- dist/
only:
- Android
- tags
tags:
- unity
upload_to_minio:
stage: deploy
patch:
stage: patch
dependencies:
- unity
script:
- apt update; apt -y install tar
- mv dist/src ./unity-src
- cd unity-src
- cp -rf ../patches.sh .
- cp -rf ../misc .
- chmod +x *.sh
- sed -i '/>UIStatusBarStyle</i\ <key>UIFileSharingEnabled</key>\n <true />\n <key>LSSupportsOpeningDocumentsInPlace</key>\n <true />' output/Info.plist
- patch -p1 < ../misc/patches/iPhone_Sensors.mm.patch
- echo '#define UNITY_USES_LOCATION 0' >> ./Classes/Preprocessor.h
- tar zcvf ../dist/KoishiPro2-src.tar.gz * .*
- cd ..
artifacts:
paths:
- dist/
only:
- Android
- tags
tags:
- linux
upload_to_minio_latest:
stage: deploy
dependencies:
- patch
tags:
- linux
image: python
script:
- pip install -U awscli
- aws s3 --endpoint=https://minio.mycard.moe:9000 sync --delete dist/ s3://mycard/koishipro2/latest
only:
- Android
- tags
upload_to_minio_tag:
stage: deploy
dependencies:
- patch
tags:
- linux
image: python
script:
- pip install -U awscli
- aws s3 --endpoint=https://minio.mycard.moe:9000 sync --delete KoishiPro2-src/ s3://mycard/koishipro2/$CI_COMMIT_TAG
- aws s3 --endpoint=https://minio.mycard.moe:9000 sync --delete dist/ s3://mycard/koishipro2/$CI_COMMIT_TAG
only:
- tags
#include <iostream>
#import <UIKit/UIKit.h>
using namespace std;
namespace core {
template <class type>
class StringStorageDefault {};
template <class type,class type2>
class basic_string {
public:
char * str;
basic_string( char* arg){
str = arg;
}
};
}
void OpenURLInGame(core::basic_string< char,core::StringStorageDefault<char> > const&arg){}
void OpenURL(core::basic_string<char,core::StringStorageDefault<char> >const &arg){
const void *arg2 = arg.str;
UIApplication *app = [UIApplication sharedApplication];
NSString *urlStr = [NSString stringWithUTF8String:(char *)arg2];
NSURL *url = [NSURL URLWithString:urlStr];
[app openURL:url];
}
void OpenURL(std::string const &arg){
UIApplication *app = [UIApplication sharedApplication];
NSString *urlStr = [NSString stringWithUTF8String:arg.c_str()];
NSURL *url = [NSURL URLWithString:urlStr];
[app openURL:url];
}
diff --git a/Classes/Preprocessor.h b/Classes/Preprocessor.h
--- a/Classes/Preprocessor.h
+++ b/Classes/Preprocessor.h
@@ -121,6 +121,7 @@
#define UNITY_USES_REPLAY_KIT 0
#define UNITY_SNAPSHOT_VIEW_ON_APPLICATION_PAUSE 0
#define UNITY_DEVELOPER_BUILD 0
+#define UNITY_USES_LOCATION 0
#define USE_IL2CPP_PCH 0
#define UNITY_SUPPORT_ROTATION PLATFORM_IOS
diff --git a/Classes/iPhone_Sensors.mm b/Classes/iPhone_Sensors.mm
--- a/Classes/iPhone_Sensors.mm
+++ b/Classes/iPhone_Sensors.mm
@@ -1,7 +1,11 @@
#define SIMULATE_ATTITUDE_FROM_GRAVITY 1
#import "iPhone_Sensors.h"
+
+#if UNITY_USES_LOCATION
#import <CoreLocation/CoreLocation.h>
+#endif
+
#if !PLATFORM_TVOS
#import <CoreMotion/CoreMotion.h>
#endif
@@ -767,9 +771,10 @@ extern "C" void UnityGetNiceKeyname(int
#pragma clang diagnostic pop
-
+#if UNITY_USES_LOCATION
@interface LocationServiceDelegate : NSObject<CLLocationManagerDelegate>
@end
+#endif
void
UnitySetLastLocation(double timestamp,
@@ -785,6 +790,7 @@ UnitySetLastHeading(float magneticHeadin
float rawX, float rawY, float rawZ,
double timestamp);
+#if UNITY_USES_LOCATION
struct LocationServiceInfo
{
private:
@@ -825,40 +831,56 @@ CLLocationManager* LocationServiceInfo::
return locationManager;
}
+#endif
+
bool LocationService::IsServiceEnabledByUser()
{
+#if UNITY_USES_LOCATION
return [CLLocationManager locationServicesEnabled];
+#else
+ return false;
+#endif
}
void LocationService::SetDesiredAccuracy(float val)
{
+#if UNITY_USES_LOCATION
gLocationServiceStatus.desiredAccuracy = val;
+#endif
}
float LocationService::GetDesiredAccuracy()
{
+#if UNITY_USES_LOCATION
return gLocationServiceStatus.desiredAccuracy;
+#else
+ return NAN;
+#endif
}
void LocationService::SetDistanceFilter(float val)
{
+#if UNITY_USES_LOCATION
gLocationServiceStatus.distanceFilter = val;
+#endif
}
float LocationService::GetDistanceFilter()
{
+#if UNITY_USES_LOCATION
return gLocationServiceStatus.distanceFilter;
+#else
+ return NAN;
+#endif
}
void LocationService::StartUpdatingLocation()
{
+#if UNITY_USES_LOCATION
if (gLocationServiceStatus.locationStatus != kLocationServiceRunning)
{
CLLocationManager* locationManager = gLocationServiceStatus.GetLocationManager();
-
- // request authorization on ios8
- if ([locationManager respondsToSelector: @selector(requestWhenInUseAuthorization)])
- [locationManager performSelector: @selector(requestWhenInUseAuthorization)];
+ [locationManager requestWhenInUseAuthorization];
locationManager.desiredAccuracy = gLocationServiceStatus.desiredAccuracy;
// Set a movement threshold for new events
@@ -872,20 +894,23 @@ void LocationService::StartUpdatingLocat
gLocationServiceStatus.locationStatus = kLocationServiceInitializing;
}
+#endif
}
void LocationService::StopUpdatingLocation()
{
+#if UNITY_USES_LOCATION
if (gLocationServiceStatus.locationStatus != kLocationServiceStopped)
{
[gLocationServiceStatus.GetLocationManager() stopUpdatingLocation];
gLocationServiceStatus.locationStatus = kLocationServiceStopped;
}
+#endif
}
void LocationService::SetHeadingUpdatesEnabled(bool enabled)
{
-#if PLATFORM_IOS
+#if PLATFORM_IOS && UNITY_USES_LOCATION
if (enabled)
{
if (gLocationServiceStatus.headingStatus != kLocationServiceRunning &&
@@ -910,28 +935,41 @@ void LocationService::SetHeadingUpdatesE
bool LocationService::IsHeadingUpdatesEnabled()
{
+#if UNITY_USES_LOCATION
return (gLocationServiceStatus.headingStatus == kLocationServiceRunning);
+#else
+ return false;
+#endif
}
int UnityGetLocationStatus()
{
- return gLocationServiceStatus.locationStatus;
+#if UNITY_USES_LOCATION
+ return (LocationServiceStatus)gLocationServiceStatus.locationStatus;
+#else
+ return kLocationServiceFailed;
+#endif
}
int UnityGetHeadingStatus()
{
- return gLocationServiceStatus.headingStatus;
+#if UNITY_USES_LOCATION
+ return (LocationServiceStatus)gLocationServiceStatus.headingStatus;
+#else
+ return kLocationServiceFailed;
+#endif
}
bool LocationService::IsHeadingAvailable()
{
-#if PLATFORM_TVOS
+#if PLATFORM_IOS && UNITY_USES_LOCATION
+ return [CLLocationManager headingAvailable];
+#else
return false;
-#else
- return [CLLocationManager headingAvailable];
#endif
}
+#if UNITY_USES_LOCATION
@implementation LocationServiceDelegate
- (void)locationManager:(CLLocationManager*)manager didUpdateLocations:(NSArray*)locations
@@ -973,6 +1011,7 @@ bool LocationService::IsHeadingAvailable
}
@end
+#endif
#if PLATFORM_TVOS
diff --git a/Classes/Preprocessor.h b/Classes/Preprocessor.h
--- a/Classes/Preprocessor.h
+++ b/Classes/Preprocessor.h
@@ -100,6 +100,7 @@
#define UNITY_USES_WEBCAM 0
#define UNITY_USES_MICROPHONE 0
#define UNITY_USES_REPLAY_KIT 0
+#define UNITY_USES_LOCATION 0
#define UNITY_SNAPSHOT_VIEW_ON_APPLICATION_PAUSE 1
#define USE_IL2CPP_PCH 0
diff --git a/Classes/iPhone_Sensors.mm b/Classes/iPhone_Sensors.mm
--- a/Classes/iPhone_Sensors.mm
+++ b/Classes/iPhone_Sensors.mm
@@ -1,7 +1,9 @@
#define SIMULATE_ATTITUDE_FROM_GRAVITY 1
#import "iPhone_Sensors.h"
+#if UNITY_USES_LOCATION
#import <CoreLocation/CoreLocation.h>
+#endif
#if !UNITY_TVOS
#import <CoreMotion/CoreMotion.h>
#endif
@@ -752,9 +754,10 @@ extern "C" void UnityGetNiceKeyname(int
#pragma clang diagnostic pop
-
+#if UNITY_USES_LOCATION
@interface LocationServiceDelegate : NSObject<CLLocationManagerDelegate>
@end
+#endif
void
UnitySetLastLocation(double timestamp,
@@ -770,6 +773,7 @@ UnitySetLastHeading(float magneticHeadin
float rawX, float rawY, float rawZ,
double timestamp);
+#if UNITY_USES_LOCATION
struct LocationServiceInfo
{
private:
@@ -795,7 +799,9 @@ LocationServiceInfo::LocationServiceInfo
headingStatus = kLocationServiceStopped;
}
+#if UNITY_USES_LOCATION
static LocationServiceInfo gLocationServiceStatus;
+#endif
CLLocationManager* LocationServiceInfo::GetLocationManager()
{
@@ -810,40 +816,56 @@ CLLocationManager* LocationServiceInfo::
return locationManager;
}
+#endif
+
bool LocationService::IsServiceEnabledByUser()
{
+#if UNITY_USES_LOCATION
return [CLLocationManager locationServicesEnabled];
+#else
+ return false;
+#endif
}
void LocationService::SetDesiredAccuracy(float val)
{
+#if UNITY_USES_LOCATION
gLocationServiceStatus.desiredAccuracy = val;
+#endif
}
float LocationService::GetDesiredAccuracy()
{
+#if UNITY_USES_LOCATION
return gLocationServiceStatus.desiredAccuracy;
+#else
+ return NAN;
+#endif
}
void LocationService::SetDistanceFilter(float val)
{
+#if UNITY_USES_LOCATION
gLocationServiceStatus.distanceFilter = val;
+#endif
}
float LocationService::GetDistanceFilter()
{
+#if UNITY_USES_LOCATION
return gLocationServiceStatus.distanceFilter;
+#else
+ return NAN;
+#endif
}
void LocationService::StartUpdatingLocation()
{
+#if UNITY_USES_LOCATION
if (gLocationServiceStatus.locationStatus != kLocationServiceRunning)
{
CLLocationManager* locationManager = gLocationServiceStatus.GetLocationManager();
-
- // request authorization on ios8
- if ([locationManager respondsToSelector: @selector(requestWhenInUseAuthorization)])
- [locationManager performSelector: @selector(requestWhenInUseAuthorization)];
+ [locationManager requestWhenInUseAuthorization];
locationManager.desiredAccuracy = gLocationServiceStatus.desiredAccuracy;
// Set a movement threshold for new events
@@ -857,20 +879,23 @@ void LocationService::StartUpdatingLocat
gLocationServiceStatus.locationStatus = kLocationServiceInitializing;
}
+#endif
}
void LocationService::StopUpdatingLocation()
{
+#if UNITY_USES_LOCATION
if (gLocationServiceStatus.locationStatus != kLocationServiceStopped)
{
[gLocationServiceStatus.GetLocationManager() stopUpdatingLocation];
gLocationServiceStatus.locationStatus = kLocationServiceStopped;
}
+#endif
}
void LocationService::SetHeadingUpdatesEnabled(bool enabled)
{
-#if UNITY_IOS
+#if UNITY_IOS && UNITY_USES_LOCATION
if (enabled)
{
if (gLocationServiceStatus.headingStatus != kLocationServiceRunning &&
@@ -895,28 +920,41 @@ void LocationService::SetHeadingUpdatesE
bool LocationService::IsHeadingUpdatesEnabled()
{
+#if UNITY_USES_LOCATION
return (gLocationServiceStatus.headingStatus == kLocationServiceRunning);
+#else
+ return false;
+#endif
}
int UnityGetLocationStatus()
{
+#if UNITY_USES_LOCATION
return gLocationServiceStatus.locationStatus;
+#else
+ return kLocationServiceFailed;
+#endif
}
int UnityGetHeadingStatus()
{
+#if UNITY_USES_LOCATION
return gLocationServiceStatus.headingStatus;
+#else
+ return kLocationServiceFailed;
+#endif
}
bool LocationService::IsHeadingAvailable()
{
-#if UNITY_TVOS
- return false;
-#else
+#if PLATFORM_IOS && UNITY_USES_LOCATION
return [CLLocationManager headingAvailable];
+#else
+ return false;
#endif
}
+#if UNITY_USES_LOCATION
@implementation LocationServiceDelegate
- (void)locationManager:(CLLocationManager*)manager didUpdateLocations:(NSArray*)locations
@@ -958,6 +996,7 @@ bool LocationService::IsHeadingAvailable
}
@end
+#endif
#if UNITY_TVOS
GCMicroGamepad* QueryMicroController()
#!/bin/bash
MM_PATH="./misc/URLUtility.mm"
IPHONE_SDK_PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
_run_for_arch() {
TARGET_ARCH=$1
OUTPUT_PATH=$2
echo "Running for $TARGET_ARCH to $OUTPUT_PATH"
lipo ./Libraries/libiPhone-lib.a -thin "$TARGET_ARCH" -output "$OUTPUT_PATH"
ar -d "$OUTPUT_PATH" URLUtility.o
clang -c "$MM_PATH" -arch "$TARGET_ARCH" -isysroot "$IPHONE_SDK_PATH"
ar -q "$OUTPUT_PATH" ./URLUtility.o
rm -f ./URLUtility.o
}
mkdir /tmp/tmp-libs
_run_for_arch arm64 /tmp/tmp-libs/libiPhone-lib-arm64.a
_run_for_arch armv7 /tmp/tmp-libs/libiPhone-lib-armv7.a
_run_for_arch armv7s /tmp/tmp-libs/libiPhone-lib-armv7s.a
lipo -create /tmp/tmp-libs/libiPhone-lib-arm64.a /tmp/tmp-libs/libiPhone-lib-armv7.a /tmp/tmp-libs/libiPhone-lib-armv7s.a -output ./Libraries/libiPhone-lib-new.a
# patch -p1 < ./misc/patches/iPhone_Sensors.mm.patch
# echo '#define UNITY_USES_LOCATION 0' >> ./Classes/Preprocessor.h
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment