Makefile 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. .POSIX:
  2. # Cargo binary
  3. CARGO = cargo
  4. RELEASE_APK = target/android-artifacts/release/apk/darkfi-app.apk
  5. DEBUG_APK = target/android-artifacts/debug/apk/darkfi-app.apk
  6. #ADB_DEVICE = -s DEVICE_ID
  7. ADB_DEVICE =
  8. SRC = \
  9. build.rs \
  10. Cargo.lock \
  11. Cargo.toml \
  12. Dockerfile \
  13. $(shell find assets -type f) \
  14. $(shell find src -type f)
  15. RELEASE_FEATURES = --features=enable-plugins
  16. DEBUG_FEATURES = --features=enable-filelog,enable-plugins
  17. #DEV_FEATURES = --features=enable-filelog,enable-netdebug,emulate-android
  18. #DEV_FEATURES = --features=enable-filelog,enable-netdebug,enable-plugins
  19. DEV_FEATURES = --features=enable-plugins
  20. default: build-release
  21. ./darkfi-app
  22. android: android-release
  23. # Platform release builds
  24. ios-release: $(SRC) fonts forest_720x1280 forest_1920x1080
  25. # Create the app bundle structure
  26. rm -rf DarkFi.app
  27. mkdir -p DarkFi.app
  28. # Build for iOS device (aarch64)
  29. SDKROOT=$$(xcrun --sdk iphoneos --show-sdk-path 2>/dev/null); \
  30. if [ -z "$$SDKROOT" ]; then \
  31. SDKROOT=$$(xcodebuild -version -sdk iphoneos Path 2>/dev/null); \
  32. fi; \
  33. if [ -z "$$SDKROOT" ]; then \
  34. echo "ERROR: Could not find iphoneos SDK."; \
  35. echo "Current xcode-select path: $$(xcode-select -p)"; \
  36. echo "Ensure Xcode is installed and selected: sudo xcode-select -s /Applications/Xcode.app"; \
  37. exit 1; \
  38. fi; \
  39. export SDKROOT=$$SDKROOT; \
  40. export IPHONEOS_DEPLOYMENT_TARGET=14.0; \
  41. cargo build --target aarch64-apple-ios --release $(RELEASE_FEATURES)
  42. # Copy the binary
  43. cp target/aarch64-apple-ios/release/darkfi-app DarkFi.app/
  44. # Copy resources
  45. cp ios-Info.plist DarkFi.app/Info.plist
  46. cp -r assets/lang DarkFi.app/
  47. cp -r assets/forest_720x1280 DarkFi.app/
  48. cp -r assets/forest_1920x1080 DarkFi.app/
  49. cp assets/*.png DarkFi.app/ || true
  50. cp embedded.mobileprovision DarkFi.app/ || echo "Warning: No provisioning profile found. Device builds will fail to launch."
  51. cp ibm-plex-mono-regular.otf DarkFi.app/
  52. cp NotoColorEmoji.ttf DarkFi.app/
  53. # Sign the app bundle with entitlements
  54. codesign --force --sign - --entitlements DarkFi.entitlements --timestamp=none DarkFi.app
  55. # Create a dummy PkgInfo (optional but good practice)
  56. echo "APPL????" > DarkFi.app/PkgInfo
  57. @echo "DarkFi.app built for device (aarch64)."
  58. ios-sim: $(SRC) fonts forest_720x1280 forest_1920x1080
  59. # Create the app bundle structure
  60. rm -rf DarkFi.app
  61. mkdir -p DarkFi.app
  62. # Build for iOS simulator (Detect Arch)
  63. SDKROOT=$$(xcrun --sdk iphonesimulator --show-sdk-path 2>/dev/null); \
  64. if [ -z "$$SDKROOT" ]; then \
  65. SDKROOT=$$(xcodebuild -version -sdk iphonesimulator Path 2>/dev/null); \
  66. fi; \
  67. if [ -z "$$SDKROOT" ]; then \
  68. echo "ERROR: Could not find iphonesimulator SDK."; \
  69. echo "Current xcode-select path: $$(xcode-select -p)"; \
  70. echo "Ensure Xcode is installed and selected: sudo xcode-select -s /Applications/Xcode.app"; \
  71. exit 1; \
  72. fi; \
  73. export SDKROOT=$$SDKROOT; \
  74. export IPHONEOS_DEPLOYMENT_TARGET=14.0; \
  75. ARCH=$$(uname -m); \
  76. if [ "$$ARCH" = "arm64" ]; then \
  77. echo "Detected Apple Silicon (arm64). Building for aarch64-apple-ios-sim..."; \
  78. cargo build --target aarch64-apple-ios-sim --release $(RELEASE_FEATURES); \
  79. cp target/aarch64-apple-ios-sim/release/darkfi-app DarkFi.app/; \
  80. else \
  81. echo "Detected Intel (x86_64). Building for x86_64-apple-ios..."; \
  82. cargo build --target x86_64-apple-ios --release $(RELEASE_FEATURES); \
  83. cp target/x86_64-apple-ios/release/darkfi-app DarkFi.app/; \
  84. fi
  85. # Copy resources
  86. cp ios-Info.plist DarkFi.app/Info.plist
  87. cp -r assets/lang DarkFi.app/
  88. cp -r assets/forest_720x1280 DarkFi.app/
  89. cp -r assets/forest_1920x1080 DarkFi.app/
  90. cp assets/*.png DarkFi.app/ || true
  91. cp ibm-plex-mono-regular.otf DarkFi.app/
  92. cp NotoColorEmoji.ttf DarkFi.app/
  93. # Sign the app bundle with entitlements
  94. codesign --force --sign - --entitlements DarkFi.entitlements --timestamp=none DarkFi.app
  95. echo "APPL????" > DarkFi.app/PkgInfo
  96. @echo "DarkFi.app built for simulator."
  97. ios-xcode:
  98. rm -rf DarkFi.xcodeproj
  99. mkdir -p DarkFi.xcodeproj
  100. # Generate unique IDs for the project file (24 chars)
  101. sed -e "s/CONFIG_LIST_ID/$$(uuidgen | tr -d - | tr '[:lower:]' '[:upper:]' | cut -c 1-24)/g" \
  102. -e "s/MAIN_GROUP_ID/$$(uuidgen | tr -d - | tr '[:lower:]' '[:upper:]' | cut -c 1-24)/g" \
  103. -e "s/LEGACY_TARGET_ID/$$(uuidgen | tr -d - | tr '[:lower:]' '[:upper:]' | cut -c 1-24)/g" \
  104. -e "s/PROJECT_ID/$$(uuidgen | tr -d - | tr '[:lower:]' '[:upper:]' | cut -c 1-24)/g" \
  105. -e "s/PROJECT_CONFIG_LIST_ID/$$(uuidgen | tr -d - | tr '[:lower:]' '[:upper:]' | cut -c 1-24)/g" \
  106. -e "s/DEBUG_CONFIG_ID/$$(uuidgen | tr -d - | tr '[:lower:]' '[:upper:]' | cut -c 1-24)/g" \
  107. -e "s/RELEASE_CONFIG_ID/$$(uuidgen | tr -d - | tr '[:lower:]' '[:upper:]' | cut -c 1-24)/g" \
  108. project.pbxproj.template > DarkFi.xcodeproj/project.pbxproj
  109. @echo "Generated DarkFi.xcodeproj. Open it in Xcode and ensure the 'External Build Tool' configuration points to 'make' and target 'ios-release' in this directory."
  110. macos-release: build-release
  111. -mv darkfi-app darkfi-app.macos
  112. macos-debug: build-debug
  113. -mv darkfi-app darkfi-app_debug.macos
  114. linux-release: build-release
  115. -mv darkfi-app darkfi-app.linux
  116. linux-debug: build-debug
  117. -mv darkfi-app darkfi-app_debug.linux
  118. win-release: $(SRC) fonts
  119. $(CARGO) build --release $(RELEASE_FEATURES)
  120. -mv target/release/darkfi-app.exe .
  121. win-debug: $(SRC) fonts
  122. $(CARGO) build $(DEBUG_FEATURES)
  123. -mv target/debug/darkfi-app.exe .
  124. android-release: $(SRC) fonts forest_720x1280
  125. podman run -v $(shell pwd)/../../:/root/darkfi -w /root/darkfi/bin/app/ -t apk cargo quad-apk build --release $(RELEASE_FEATURES)
  126. -mv $(RELEASE_APK) darkfi-app.apk
  127. android-debug: $(SRC) fonts forest_720x1280
  128. podman run -v $(shell pwd)/../../:/root/darkfi -w /root/darkfi/bin/app/ -t apk cargo quad-apk build $(DEBUG_FEATURES)
  129. -mv $(DEBUG_APK) darkfi-app_debug.apk
  130. build-release: $(SRC) fonts forest_1920x1080
  131. $(CARGO) build --release $(RELEASE_FEATURES)
  132. -mv target/release/darkfi-app .
  133. build-debug: $(SRC) fonts forest_1920x1080
  134. $(CARGO) build $(DEBUG_FEATURES)
  135. -mv target/debug/darkfi-app .
  136. # Download font data
  137. fonts: ibm-plex-mono-regular.otf NotoColorEmoji.ttf
  138. ibm-plex-mono-regular.otf:
  139. wget -c https://codeberg.org/darkrenaissance/darkfi/raw/branch/data/ibm-plex-mono-regular.otf
  140. NotoColorEmoji.ttf:
  141. wget -c https://codeberg.org/darkrenaissance/darkfi/raw/branch/data/NotoColorEmoji.ttf
  142. forest_1920x1080.zip:
  143. wget -c https://codeberg.org/darkrenaissance/darkfi/raw/branch/data/forest_1920x1080.zip
  144. assets/forest_1920x1080/000.qoi:
  145. cd assets && unzip ../forest_1920x1080.zip
  146. forest_1920x1080: forest_1920x1080.zip assets/forest_1920x1080/000.qoi
  147. # rm -fr assets/forest_729x1280/
  148. forest_720x1280.zip:
  149. wget -c https://codeberg.org/darkrenaissance/darkfi/raw/branch/data/forest_720x1280.zip
  150. assets/forest_720x1280/000.qoi:
  151. cd assets && unzip ../forest_720x1280.zip
  152. forest_720x1280: forest_720x1280.zip assets/forest_720x1280/000.qoi
  153. # rm -fr assets/forest_1920x1080/
  154. # Developer targets
  155. dev: $(SRC) fonts forest_1920x1080
  156. $(CARGO) lbuild $(DEV_FEATURES)
  157. -mv target/debug/darkfi-app .
  158. ./darkfi-app
  159. apk: $(SRC) fonts forest_720x1280
  160. podman run -v $(shell pwd)/../../:/root/darkfi -w /root/darkfi/bin/app/ -t apk cargo quad-apk build $(DEV_FEATURES)
  161. $(MAKE) install-apk
  162. install-apk:
  163. -mv $(DEBUG_APK) .
  164. -adb $(ADB_DEVICE) uninstall darkfi.darkfi_app
  165. adb $(ADB_DEVICE) install -r darkfi-app.apk
  166. reset
  167. adb $(ADB_DEVICE) logcat -c
  168. adb $(ADB_DEVICE) shell monkey -p darkfi.darkfi_app -c android.intent.category.LAUNCHER 1
  169. adb $(ADB_DEVICE) logcat -v color -s darkfi -s SAPP -s libc -s DEBUG -s ActivityManager -s ActivityTaskManager -s WindowManager -s AndroidRuntime -s rkfi.darkfi_app | tee output.log
  170. # Useful for dev
  171. cli:
  172. podman run -v $(shell pwd)/../../:/root/darkfi -w /root/darkfi/bin/app/ -it apk bash
  173. fmt:
  174. $(CARGO) +nightly fmt
  175. clean:
  176. podman run -v $(shell pwd):/root/dw -w /root/dw -t apk rm -fr target/
  177. rm -fr target/
  178. rm -f darkfi-app.apk
  179. rm -rf DarkFi.app
  180. rm -rf DarkFi.xcodeproj
  181. .PHONY: all android cli clean