2023-09-11 19:40:37 +03:30
i n c l u d e d e p e n d e n c i e s . p r o p e r t i e s
2023-08-19 22:27:23 +03:30
BINDIR = ./libcore/bin
ANDROID_OUT = ./android/app/libs
2023-12-25 20:08:04 +03:30
IOS_OUT = ./ios/Frameworks
2023-08-19 22:27:23 +03:30
DESKTOP_OUT = ./libcore/bin
GEO_ASSETS_DIR = ./assets/core
2023-09-11 19:40:37 +03:30
2023-10-17 03:15:15 +03:30
CORE_PRODUCT_NAME = libcore
CORE_NAME = hiddify-$( CORE_PRODUCT_NAME)
2023-09-22 14:16:21 +03:30
i f e q ( $( CHANNEL ) , p r o d )
2023-09-11 21:19:55 +03:30
CORE_URL = https://github.com/hiddify/hiddify-next-core/releases/download/v$( core.version)
2023-09-12 10:10:14 +02:00
e l s e
CORE_URL = https://github.com/hiddify/hiddify-next-core/releases/download/draft
2023-09-12 10:04:07 +02:00
e n d i f
2023-09-12 10:10:14 +02:00
2023-09-22 14:16:21 +03:30
i f e q ( $( CHANNEL ) , p r o d )
2023-12-04 17:50:09 +03:30
TARGET = lib/main_prod.dart
2023-09-12 15:22:58 +03:30
e l s e
2023-12-04 17:50:09 +03:30
TARGET = lib/main.dart
2023-09-12 15:22:58 +03:30
e n d i f
2023-09-22 14:16:21 +03:30
2023-09-17 01:13:01 +03:30
BUILD_ARGS = --dart-define sentry_dsn = $( SENTRY_DSN)
DISTRIBUTOR_ARGS = --skip-clean --build-target $( TARGET) --build-dart-define sentry_dsn = $( SENTRY_DSN)
2023-09-12 15:22:58 +03:30
2023-07-06 17:18:41 +03:30
get :
2023-07-18 01:38:39 +03:30
flutter pub get
2023-07-19 15:37:37 +02:00
2023-07-06 17:18:41 +03:30
gen :
dart run build_runner build --delete-conflicting-outputs
2023-07-19 15:37:37 +02:00
2023-07-06 17:18:41 +03:30
translate :
dart run slang
2023-11-12 20:30:12 +03:30
prepare : get -geo -assets get gen translate
2023-12-06 01:06:33 +03:30
@echo "Available platforms:"
@echo "android"
@echo "windows"
@echo "linux"
@echo "macos"
@echo "ios"
if [ -z " $$ platform " ] ; then \
read -p "run make prepare platform=ios or Enter platform name: " choice; \
else \
choice = $$ platform; \
fi ; \
make $$ choice-libs
2023-11-07 17:22:30 +01:00
2023-10-02 16:29:51 +02:00
sync_translate :
2023-10-05 15:22:48 +02:00
cd .github && bash sync_translate.sh
make translate
2023-10-02 16:29:51 +02:00
2023-09-15 09:26:49 +02:00
android-release : android -apk -release
2023-09-12 15:22:58 +03:30
2023-09-15 23:09:58 +03:30
android-apk-release :
2023-09-17 01:13:01 +03:30
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi --target $( TARGET) $( BUILD_ARGS)
2023-10-15 15:56:26 +03:30
ls -R build/app/outputs
2023-07-19 12:57:16 +02:00
2023-08-20 12:05:11 +00:00
android-aab-release :
2023-09-17 01:13:01 +03:30
flutter build appbundle --target $( TARGET) $( BUILD_ARGS) --dart-define release = google-play
2023-10-15 15:56:26 +03:30
ls -R build/app/outputs
2023-08-20 12:05:11 +00:00
2023-08-20 10:40:47 +00:00
windows-release :
2023-09-16 00:56:03 +03:30
flutter_distributor package --platform windows --targets exe $( DISTRIBUTOR_ARGS)
2023-07-19 12:57:16 +02:00
2023-08-20 10:40:47 +00:00
linux-release :
2023-09-16 00:56:03 +03:30
flutter_distributor package --platform linux --targets appimage $( DISTRIBUTOR_ARGS)
2023-08-19 22:27:23 +03:30
2023-08-20 10:40:47 +00:00
macos-release :
2023-09-16 00:56:03 +03:30
flutter_distributor package --platform macos --targets dmg $( DISTRIBUTOR_ARGS)
2023-08-19 22:27:23 +03:30
2023-08-20 14:03:21 +00:00
ios-release : #not tested
2023-09-16 01:02:20 +03:30
flutter_distributor package --platform ios --targets ipa --build-export-options-plist ios/exportOptions.plist $( DISTRIBUTOR_ARGS)
2023-08-20 14:03:21 +00:00
2023-09-11 21:19:55 +03:30
android-libs :
2023-08-19 22:27:23 +03:30
mkdir -p $( ANDROID_OUT)
2023-09-11 21:19:55 +03:30
curl -L $( CORE_URL) /$( CORE_NAME) -android.aar.gz | gunzip > $( ANDROID_OUT) /libcore.aar
2023-07-06 17:18:41 +03:30
2023-09-15 09:32:29 +02:00
android-apk-libs : android -libs
android-aab-libs : android -libs
2023-08-20 10:40:47 +00:00
windows-libs :
2023-08-19 22:27:23 +03:30
mkdir -p $( DESKTOP_OUT)
2023-09-11 21:19:55 +03:30
curl -L $( CORE_URL) /$( CORE_NAME) -windows-amd64.dll.gz | gunzip > $( DESKTOP_OUT) /libcore.dll
2023-07-19 13:12:18 +02:00
2023-08-20 10:40:47 +00:00
linux-libs :
2023-08-19 22:27:23 +03:30
mkdir -p $( DESKTOP_OUT)
2023-09-11 21:19:55 +03:30
curl -L $( CORE_URL) /$( CORE_NAME) -linux-amd64.so.gz | gunzip > $( DESKTOP_OUT) /libcore.so
2023-07-22 00:16:46 +02:00
2023-08-20 10:47:40 +00:00
macos-libs :
2023-07-22 10:45:10 +02:00
mkdir -p $( DESKTOP_OUT) / && \
2023-09-11 21:19:55 +03:30
curl -L $( CORE_URL) /$( CORE_NAME) -macos-universal.dylib.gz | gunzip > $( DESKTOP_OUT) /libcore.dylib
2023-07-22 00:16:46 +02:00
2023-08-20 14:03:21 +00:00
ios-libs : #not tested
2024-01-08 17:30:45 +03:30
mkdir -p $( DESKTOP_OUT) / && \
rm -rf $( IOS_OUT) /Libcore.xcframework && \
2023-10-24 11:26:21 +02:00
curl -L $( CORE_URL) /$( CORE_NAME) -ios.xcframework.tar.gz | tar xz -C " $( IOS_OUT) " && \
2023-12-25 22:12:25 +03:30
mv $( IOS_OUT) /$( CORE_NAME) -ios.xcframework $( IOS_OUT) /Libcore.xcframework
2023-08-20 14:03:21 +00:00
2023-08-19 22:27:23 +03:30
get-geo-assets :
curl -L https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db -o $( GEO_ASSETS_DIR) /geoip.db
2023-08-22 01:01:55 +03:30
curl -L https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db -o $( GEO_ASSETS_DIR) /geosite.db
2023-08-19 22:27:23 +03:30
build-headers :
2023-09-11 21:19:55 +03:30
make -C libcore -f Makefile headers && mv $( BINDIR) /$( CORE_NAME) -headers.h $( BINDIR) /libcore.h
2023-08-19 22:27:23 +03:30
2023-07-21 22:16:43 +03:30
build-android-libs :
2023-09-11 21:19:55 +03:30
make -C libcore -f Makefile android && mv $( BINDIR) /$( CORE_NAME) -android.aar $( ANDROID_OUT) /libcore.aar
2023-07-21 22:16:43 +03:30
build-windows-libs :
2023-09-11 21:19:55 +03:30
make -C libcore -f Makefile windows-amd64 && mv $( BINDIR) /$( CORE_NAME) -windows-amd64.dll $( DESKTOP_OUT) /libcore.dll
2023-07-21 22:16:43 +03:30
2023-07-22 00:16:46 +02:00
build-linux-libs :
2023-11-13 14:03:36 +08:00
make -C libcore -f Makefile linux-amd64 && mv $( BINDIR) /$( CORE_NAME) -linux-amd64.so $( DESKTOP_OUT) /libcore.so
2023-08-20 09:17:10 +00:00
build-macos-libs :
2023-09-11 21:19:55 +03:30
make -C libcore -f Makefile macos-universal && mv $( BINDIR) /$( CORE_NAME) -macos-universal.dylib $( DESKTOP_OUT) /libcore.dylib
2023-08-20 14:03:21 +00:00
2023-10-24 11:26:21 +02:00
build-ios-libs :
2024-01-08 17:30:45 +03:30
rm -rf $( IOS_OUT) /Libcore.xcframework && \
make -C libcore -f Makefile ios && \
mv $( BINDIR) /$( CORE_NAME) -ios.xcframework $( IOS_OUT) /Libcore.xcframework
2023-09-15 10:44:41 +02:00
2023-09-22 14:16:21 +03:30
release : # Create a new tag for release.
2023-09-15 10:44:41 +02:00
@echo " previous version was $$ (git describe --tags $$ (git rev-list --tags --max-count=1)) "
@echo "WARNING: This operation will creates version tag and push to github"
@bash -c ' \
read -p "Version? (provide the next x.y.z semver) : " TAG && \
echo $$ TAG && \
[ [ " $$ TAG " = ~ ^[ 0-9] { 1,2} \. [ 0-9] { 1,2} \. [ 0-9] { 1,2} ( \. dev) ?$$ ] ] || { echo "Incorrect tag. e.g., 1.2.3 or 1.2.3.dev" ; exit 1; } && \
IFS = "." read -r -a VERSION_ARRAY <<< " $$ TAG " && \
2023-09-15 11:08:21 +02:00
VERSION_STR = " $$ {VERSION_ARRAY[0]}. $$ {VERSION_ARRAY[1]}. $$ {VERSION_ARRAY[2]} " && \
2023-09-22 21:46:32 +02:00
BUILD_NUMBER = $$ ( ( $$ { VERSION_ARRAY[ 0] } * 10000 + $$ { VERSION_ARRAY[ 1] } * 100 + $$ { VERSION_ARRAY[ 2] } ) ) && \
echo " version: $$ {VERSION_STR}+ $$ {BUILD_NUMBER} " && \
2023-11-13 19:08:26 +03:30
sed -i " s/^version: .*/version: $$ {VERSION_STR}\+ $$ {BUILD_NUMBER}/g " pubspec.yaml && \
2023-09-15 11:08:21 +02:00
git tag $$ { TAG} > /dev/null && \
git tag -d $$ { TAG} > /dev/null && \
2023-10-24 11:26:57 +02:00
git add pubspec.yaml CHANGELOG.md && \
2023-09-22 14:16:21 +03:30
git commit -m " release: version $$ {TAG} " && \
2023-09-15 11:23:45 +02:00
echo " creating git tag : v $$ {TAG} " && \
git tag v$$ { TAG} && \
2023-09-15 11:08:21 +02:00
git push -u origin HEAD --tags && \
2023-10-17 03:15:15 +03:30
echo "Github Actions will detect the new tag and release the new version." '
2023-12-06 01:06:33 +03:30
2023-12-25 22:12:25 +03:30
ios-temp-prepare :
2023-12-06 01:06:33 +03:30
flutter upgrade
2023-12-26 11:35:49 +03:30
flutter clean
2023-12-06 01:06:33 +03:30
flutter pub upgrade
2023-12-26 11:35:49 +03:30
#make prepare platform=ios
make get-geo-assets
make get
make gen
make translate
2023-12-06 01:06:33 +03:30
flutter build ios-framework
cd ios
2023-12-26 11:35:49 +03:30
#pod install
2023-12-06 01:06:33 +03:30
cd ..
flutter run
#Link the built App and Flutter and url_launcher_ios frameworks (or all created frameworks? i dunno, but i tried) from Release folder to Xcode project in Runner target’ s Build Phases as Linked
#change ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to $(inherited)
#also add $(inherited) as 1st option to OTHER_LDFLAGS (Other Linker Flags)
#add $(PROJECT_DIR)/Flutter/$(CONFIGURATION) to framework search path as 2nd
#in Runner target go to Build Phases in Copy Bundle Resources section remove Runner.app
# right click on Runner.xcodeproj click on Show Package Content open project.pbxproj replace
#Flutter/Release/App.xcframework
#Flutter/Release/Flutter.xcframework
# Flutter/Release/url_launcher_ios.xcframework
# with
# "Flutter/$(CONFIGURATION)/App.xcframework"
# "Flutter/$(CONFIGURATION)/Flutter.xcframework"
# "Flutter/$(CONFIGURATION)/url_launcher_ios.xcframework"
# (if you added all frameworks, you should do this pattern for all of them too, you need this step to be able to run on simulators)
# done remove # GeneratedPluginRegistrant.h # GeneratedPluginRegistrant.m # from Runner folder and add newly generated ones from build/ios/framework folder to Xcode and also check the copy box
# done in pod file # remove comment from line 2 and change it to # platform :ios, '12.1' # and add
# target.build_configurations.each do |config|
# config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.1'
# end
# before 1st ‘ end’ in post_install function
# add
# -fcxx-modules
# to
# OTHER_CPLUSPLUSFLAGS
# in Build Settings
# as 1st option
# flutter upgrade
# flutter pub upgrade
# cd ios
# pod install
# (note: i removed group and network extensions from targets to be able to build with free account)
# now build
# it will build (even on simulator)
# but for some not known reason, it will not run for me on my device and will refuse to install on simulator, maybe because the removed extensions? i dunno
# even now it can be an arsehole and return failed with exit code 1 so don’ t panic