Files
umbrix/Makefile

227 lines
8.1 KiB
Makefile
Raw Normal View History

2023-09-11 19:40:37 +03:30
include dependencies.properties
2024-02-09 21:57:49 +01:00
MKDIR := mkdir -p
RM := rm -rf
SEP :=/
ifeq ($(OS),Windows_NT)
ifeq ($(IS_GITHUB_ACTIONS),)
MKDIR := -mkdir
RM := rmdir /s /q
SEP:=\\
endif
2024-02-03 16:53:33 +01:00
endif
2023-09-11 19:40:37 +03:30
2024-02-03 16:53:33 +01:00
BINDIR=libcore$(SEP)bin
ANDROID_OUT=android$(SEP)app$(SEP)libs
IOS_OUT=ios$(SEP)Frameworks
DESKTOP_OUT=libcore$(SEP)bin
GEO_ASSETS_DIR=assets$(SEP)core
2023-09-11 19:40:37 +03:30
CORE_PRODUCT_NAME=hiddify-core
CORE_NAME=$(CORE_PRODUCT_NAME)
2024-02-10 11:20:56 +03:30
LIB_NAME=libcore
2024-02-03 16:53:33 +01:00
SRV_NAME=HiddifyService
2023-09-22 14:16:21 +03:30
ifeq ($(CHANNEL),prod)
2024-02-10 11:20:56 +03:30
CORE_URL=https://github.com/hiddify/hiddify-next-core/releases/download/v$(core.version)
2023-09-12 10:10:14 +02:00
else
2024-02-10 11:20:56 +03:30
CORE_URL=https://github.com/hiddify/hiddify-next-core/releases/download/draft
2023-09-12 10:04:07 +02:00
endif
2023-09-12 10:10:14 +02:00
2023-09-22 14:16:21 +03:30
ifeq ($(CHANNEL),prod)
2024-02-10 11:20:56 +03:30
TARGET=lib/main_prod.dart
2023-09-12 15:22:58 +03:30
else
2024-02-10 11:20:56 +03:30
TARGET=lib/main.dart
2023-09-12 15:22:58 +03:30
endif
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
2024-02-03 16:53:33 +01:00
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
2024-02-03 16:53:33 +01:00
2024-02-09 15:20:13 +03:30
prepare:
2024-02-03 16:53:33 +01:00
@echo use the following commands to prepare the library for each platform:
2024-02-03 17:39:13 +01:00
@echo make android-prepare
@echo make windows-prepare
@echo make linux-prepare
@echo make macos-prepare
@echo make ios-prepare
windows-prepare: get-geo-assets get gen translate windows-libs
ios-prepare: get-geo-assets get gen translate ios-libs
macos-prepare: get-geo-assets get gen translate macos-libs
linux-prepare: get-geo-assets get gen translate linux-libs
2024-02-09 18:36:27 +01:00
linux-appimage-prepare:linux-prepare
linux-rpm-prepare:linux-prepare
linux-deb-prepare:linux-prepare
android-prepare: get-geo-assets get gen translate android-libs
2024-02-09 18:36:27 +01:00
android-apk-prepare:android-prepare
android-aab-prepare:android-prepare
2024-02-03 16:53:33 +01:00
2024-02-09 21:07:47 +01:00
macos-install-dependencies:
brew install create-dmg tree
npm install -g appdmg
2024-02-09 21:29:11 +01:00
dart pub global activate flutter_distributor
2024-02-09 21:07:47 +01:00
ios-install-dependencies:
echo "not yet implemented"
android-install-dependencies:
echo "nothing yet"
android-apk-install-dependencies: android-install-dependencies
android-aab-install-dependencies: android-install-dependencies
linux-install-dependencies:
if [ "$(flutter)" = "true" ]; then \
wget -O ~/Downloads/flutter_linux_3.16.9-stable.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.16.9-stable.tar.xz; \
mkdir -p ~/develop; \
cd ~/develop; \
tar xf ~/Downloads/flutter_linux_3.16.9-stable.tar.xz; \
export PATH="$$PATH:$$HOME/develop/flutter/bin"; \
echo 'export PATH="$$PATH:$$HOME/develop/flutter/bin"' >> ~/.bashrc; \
fi
PATH="$$PATH":"$$HOME/.pub-cache/bin"
echo 'export PATH="$$PATH:$$HOME/.pub-cache/bin"' >>~/.bashrc
sudo apt-get update
sudo apt install -y clang ninja-build pkg-config cmake libgtk-3-dev locate ninja-build pkg-config libglib2.0-dev libgio2.0-cil-dev libayatana-appindicator3-dev fuse rpm patchelf file appstream
2024-02-09 21:29:11 +01:00
2024-02-09 21:07:47 +01:00
sudo modprobe fuse
wget -O appimagetool "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
chmod +x appimagetool
sudo mv appimagetool /usr/local/bin/
2024-02-09 21:07:47 +01:00
dart pub global activate --source git https://github.com/hiddify/flutter_distributor --git-path packages/flutter_distributor
windows-install-dependencies:
2024-02-09 21:29:11 +01:00
dart pub global activate flutter_distributor
2023-11-07 17:22:30 +01:00
2024-02-10 11:20:56 +03:30
gen_translations: #generating missing translations using google 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
android-release: android-apk-release
2023-09-12 15:22: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-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
windows-release:
2024-03-08 14:16:56 +01:00
flutter_distributor package --flutter-build-args=verbose --platform windows --targets exe,msix $(DISTRIBUTOR_ARGS)
2024-02-09 20:51:26 +01:00
linux-release:
2024-03-08 14:16:56 +01:00
flutter_distributor package --flutter-build-args=verbose --platform linux --targets deb,rpm,appimage $(DISTRIBUTOR_ARGS)
2024-01-17 02:17:25 +01:00
macos-release:
flutter_distributor package --platform macos --targets dmg,pkg $(DISTRIBUTOR_ARGS)
2023-08-19 22:27:23 +03:30
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-09-11 21:19:55 +03:30
android-libs:
2024-02-03 16:53:33 +01:00
@$(MKDIR) $(ANDROID_OUT) || echo Folder already exists. Skipping...
curl -L $(CORE_URL)/$(CORE_NAME)-android.tar.gz | tar xz -C $(ANDROID_OUT)/
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
windows-libs:
2024-02-09 21:07:47 +01:00
$(MKDIR) $(DESKTOP_OUT) || echo Folder already exists. Skipping...
2024-02-09 20:51:26 +01:00
curl -L $(CORE_URL)/$(CORE_NAME)-windows-amd64.tar.gz | tar xz -C $(DESKTOP_OUT)$(SEP)
2024-02-09 21:29:11 +01:00
ls $(DESKTOP_OUT) || dir $(DESKTOP_OUT)$(SEP)
2024-02-27 16:16:18 +03:30
#$(RM) $(DESKTOP_OUT)$(SEP)HiddifyService.exe
2024-02-24 19:28:43 +01:00
#temporary disable windows service
2023-07-19 13:12:18 +02:00
linux-libs:
mkdir -p $(DESKTOP_OUT)
curl -L $(CORE_URL)/$(CORE_NAME)-linux-amd64.tar.gz | tar xz -C $(DESKTOP_OUT)/
2023-07-22 00:16:46 +02:00
2024-01-17 03:00:32 +01:00
2023-08-20 10:47:40 +00:00
macos-libs:
mkdir -p $(DESKTOP_OUT)
2024-02-03 16:53:33 +01:00
curl -L $(CORE_URL)/$(CORE_NAME)-macos-universal.tar.gz | tar xz -C $(DESKTOP_OUT)
2023-07-22 00:16:46 +02:00
ios-libs: #not tested
mkdir -p $(IOS_OUT)
rm -rf $(IOS_OUT)/Libcore.xcframework
2024-02-03 16:53:33 +01:00
curl -L $(CORE_URL)/$(CORE_NAME)-ios.tar.gz | tar xz -C "$(IOS_OUT)"
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:
make -C libcore -f Makefile android
2024-02-10 11:20:56 +03:30
mv $(BINDIR)/$(LIB_NAME).aar $(ANDROID_OUT)/
2023-07-21 22:16:43 +03:30
build-windows-libs:
make -C libcore -f Makefile windows-amd64
2023-07-21 22:16:43 +03:30
2023-07-22 00:16:46 +02:00
build-linux-libs:
make -C libcore -f Makefile linux-amd64
2023-08-20 09:17:10 +00:00
build-macos-libs:
make -C libcore -f Makefile macos-universal
build-ios-libs:
rf -rf $(IOS_OUT)/Libcore.xcframework
make -C libcore -f Makefile ios
2024-02-09 15:20:13 +03:30
mv $(BINDIR)/Libcore.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.
2024-01-26 19:07:38 +01:00
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 '\
[ "404" == $$(curl -I -s -w "%{http_code}" https://github.com/hiddify/hiddify-next-core/releases/download/v$(core.version)/hiddify-core-linux-amd64.tar.gz -o /dev/null) ]&&{ echo "Core Not Found"; exit 1 ; };\
cversion_string=`grep -e "^version:" pubspec.yaml | cut -d: -f2-`; \
cstr_version=`echo "$${cversion_string}" | sed -n "s/[ ]*\\([0-9]\\+\\.[0-9]\\+\\.[0-9]\\+\\)+.*/\\1/p"`; \
cbuild_number=`echo "$${cversion_string}" | sed -n "s/.*+\\([0-9]\\+\\)/\\1/p"`; \
echo "Current Version Name:$${cstr_version} Build Number:$${cbuild_number}";\
read -p "new Version? (provide the next x.y.z semver) : " TAG && \
2023-09-15 10:44:41 +02:00
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 && \
2024-02-27 17:00:11 +03:30
sed -i "s/^msix_version: .*/msix_version: $${VERSION_ARRAY[0]}.$${VERSION_ARRAY[1]}.$${VERSION_ARRAY[2]}.0/g" windows/packaging/msix/make_config.yaml && \
sed -i "s/CURRENT_PROJECT_VERSION = $${cbuild_number}/CURRENT_PROJECT_VERSION = $${BUILD_NUMBER}/g" ios/Runner.xcodeproj/project.pbxproj && \
sed -i "s/MARKETING_VERSION = $${cstr_version}/MARKETING_VERSION = $${VERSION_STR}/g" ios/Runner.xcodeproj/project.pbxproj && \
git add ios/Runner.xcodeproj/project.pbxproj pubspec.yaml windows/packaging/msix/make_config.yaml && \
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}" && \
2024-01-26 14:30:36 +01:00
git push && \
2023-09-15 11:23:45 +02:00
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:
2024-02-11 15:17:00 +03:30
make ios-prepare
2023-12-06 01:06:33 +03:30
flutter build ios-framework
cd ios
2024-01-08 17:40:18 +03:30
pod install
2024-01-26 14:30:36 +01:00