|
| 1 | +The end result of a build. |
| 2 | + |
| 3 | +Contains the final asset manifest, the executables, and the workdir. |
| 4 | + |
| 5 | +Every dioxus app can have an optional server executable which will influence the final bundle. |
| 6 | +This is built in parallel with the app executable during the `build` phase and the progres/status |
| 7 | +of the build is aggregated. |
| 8 | + |
| 9 | +The server will *always* be dropped into the `web` folder since it is considered "web" in nature, |
| 10 | +and will likely need to be combined with the public dir to be useful. |
| 11 | + |
| 12 | +We do our best to assemble read-to-go bundles here, such that the "bundle" step for each platform |
| 13 | +can just use the build dir |
| 14 | + |
| 15 | +When we write the AppBundle to a folder, it'll contain each bundle for each platform under the app's name: |
| 16 | +``` |
| 17 | +dog-app/ |
| 18 | + cache/ |
| 19 | + assets/ |
| 20 | + patches/ |
| 21 | + patch-xyz-1/ |
| 22 | + desktop/ |
| 23 | + mobile/ |
| 24 | + some.exe |
| 25 | + build-xyz/ |
| 26 | + web/ |
| 27 | + server.exe |
| 28 | + assets/ |
| 29 | + some-secret-asset.txt (a server-side asset) |
| 30 | + public/ |
| 31 | + index.html |
| 32 | + assets/ |
| 33 | + logo.png |
| 34 | + desktop/ |
| 35 | + App.app |
| 36 | + App.appimage |
| 37 | + App.exe |
| 38 | + server/ |
| 39 | + server |
| 40 | + assets/ |
| 41 | + some-secret-asset.txt (a server-side asset) |
| 42 | + ios/ |
| 43 | + App.app |
| 44 | + App.ipa |
| 45 | + android/ |
| 46 | + App.apk |
| 47 | + bundle/ |
| 48 | + build.json |
| 49 | + Desktop.app |
| 50 | + Mobile_x64.ipa |
| 51 | + Mobile_arm64.ipa |
| 52 | + Mobile_rosetta.ipa |
| 53 | + web.appimage |
| 54 | + web/ |
| 55 | + server.exe |
| 56 | + assets/ |
| 57 | + some-secret-asset.txt |
| 58 | + public/ |
| 59 | + index.html |
| 60 | + assets/ |
| 61 | + logo.png |
| 62 | + style.css |
| 63 | +``` |
| 64 | + |
| 65 | +When deploying, the build.json file will provide all the metadata that dx-deploy will use to |
| 66 | +push the app to stores, set up infra, manage versions, etc. |
| 67 | + |
| 68 | +The format of each build will follow the name plus some metadata such that when distributing you |
| 69 | +can easily trim off the metadata. |
| 70 | + |
| 71 | +The idea here is that we can run any of the programs in the same way that they're deployed. |
| 72 | + |
| 73 | + |
| 74 | +## Bundle structure links |
| 75 | +- apple: https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle |
| 76 | +- appimage: https://docs.appimage.org/packaging-guide/manual.html#ref-manual |
| 77 | + |
| 78 | +## Extra links |
| 79 | +- xbuild: https://github.com/rust-mobile/xbuild/blob/master/xbuild/src/command/build.rs |
| 80 | + |
| 81 | + |
| 82 | +## Web: |
| 83 | +Create a folder that is somewhat similar to an app-image (exe + asset) |
| 84 | +The server is dropped into the `web` folder, even if there's no `public` folder. |
| 85 | +If there's no server (SPA), we still use the `web` folder, but it only contains the |
| 86 | +public folder. |
| 87 | +``` |
| 88 | +web/ |
| 89 | + server |
| 90 | + assets/ |
| 91 | + public/ |
| 92 | + index.html |
| 93 | + wasm/ |
| 94 | + app.wasm |
| 95 | + glue.js |
| 96 | + snippets/ |
| 97 | + ... |
| 98 | + assets/ |
| 99 | + logo.png |
| 100 | +``` |
| 101 | + |
| 102 | +## Linux: |
| 103 | +https://docs.appimage.org/reference/appdir.html#ref-appdir |
| 104 | +current_exe.join("Assets") |
| 105 | +``` |
| 106 | +app.appimage/ |
| 107 | + AppRun |
| 108 | + app.desktop |
| 109 | + package.json |
| 110 | + assets/ |
| 111 | + logo.png |
| 112 | +``` |
| 113 | + |
| 114 | +## Macos |
| 115 | +We simply use the macos format where binaries are in `Contents/MacOS` and assets are in `Contents/Resources` |
| 116 | +We put assets in an assets dir such that it generally matches every other platform and we can |
| 117 | +output `/assets/blah` from manganis. |
| 118 | +``` |
| 119 | +App.app/ |
| 120 | + Contents/ |
| 121 | + Info.plist |
| 122 | + MacOS/ |
| 123 | + Frameworks/ |
| 124 | + Resources/ |
| 125 | + assets/ |
| 126 | + blah.icns |
| 127 | + blah.png |
| 128 | + CodeResources |
| 129 | + _CodeSignature/ |
| 130 | +``` |
| 131 | + |
| 132 | +## iOS |
| 133 | +Not the same as mac! ios apps are a bit "flattened" in comparison. simpler format, presumably |
| 134 | +since most ios apps don't ship frameworks/plugins and such. |
| 135 | + |
| 136 | +todo(jon): include the signing and entitlements in this format diagram. |
| 137 | +``` |
| 138 | +App.app/ |
| 139 | + main |
| 140 | + assets/ |
| 141 | +``` |
| 142 | + |
| 143 | +## Android: |
| 144 | + |
| 145 | +Currently we need to generate a `src` type structure, not a pre-packaged apk structure, since |
| 146 | +we need to compile kotlin and java. This pushes us into using gradle and following a structure |
| 147 | +similar to that of cargo mobile2. Eventually I'd like to slim this down (drop buildSrc) and |
| 148 | +drive the kotlin build ourselves. This would let us drop gradle (yay! no plugins!) but requires |
| 149 | +us to manage dependencies (like kotlinc) ourselves (yuck!). |
| 150 | + |
| 151 | +https://github.com/WanghongLin/miscellaneous/blob/master/tools/build-apk-manually.sh |
| 152 | + |
| 153 | +Unfortunately, it seems that while we can drop the `android` build plugin, we still will need |
| 154 | +gradle since kotlin is basically gradle-only. |
| 155 | + |
| 156 | +Pre-build: |
| 157 | +``` |
| 158 | +app.apk/ |
| 159 | + .gradle |
| 160 | + app/ |
| 161 | + src/ |
| 162 | + main/ |
| 163 | + assets/ |
| 164 | + jniLibs/ |
| 165 | + java/ |
| 166 | + kotlin/ |
| 167 | + res/ |
| 168 | + AndroidManifest.xml |
| 169 | + build.gradle.kts |
| 170 | + proguard-rules.pro |
| 171 | + buildSrc/ |
| 172 | + build.gradle.kts |
| 173 | + src/ |
| 174 | + main/ |
| 175 | + kotlin/ |
| 176 | + BuildTask.kt |
| 177 | + build.gradle.kts |
| 178 | + gradle.properties |
| 179 | + gradlew |
| 180 | + gradlew.bat |
| 181 | + settings.gradle |
| 182 | +``` |
| 183 | + |
| 184 | +Final build: |
| 185 | +``` |
| 186 | +app.apk/ |
| 187 | + AndroidManifest.xml |
| 188 | + classes.dex |
| 189 | + assets/ |
| 190 | + logo.png |
| 191 | + lib/ |
| 192 | + armeabi-v7a/ |
| 193 | + libmyapp.so |
| 194 | + arm64-v8a/ |
| 195 | + libmyapp.so |
| 196 | +``` |
| 197 | +Notice that we *could* feasibly build this ourselves :) |
| 198 | + |
| 199 | +## Windows: |
| 200 | +https://superuser.com/questions/749447/creating-a-single-file-executable-from-a-directory-in-windows |
| 201 | +Windows does not provide an AppImage format, so instead we're going build the same folder |
| 202 | +structure as an AppImage, but when distributing, we'll create a .exe that embeds the resources |
| 203 | +as an embedded .zip file. When the app runs, it will implicitly unzip its resources into the |
| 204 | +Program Files folder. Any subsequent launches of the parent .exe will simply call the AppRun.exe |
| 205 | +entrypoint in the associated Program Files folder. |
| 206 | + |
| 207 | +This is, in essence, the same as an installer, so we might eventually just support something like msi/msix |
| 208 | +which functionally do the same thing but with a sleeker UI. |
| 209 | + |
| 210 | +This means no installers are required and we can bake an updater into the host exe. |
| 211 | + |
| 212 | +## Handling asset lookups: |
| 213 | +current_exe.join("assets") |
| 214 | +``` |
| 215 | +app.appimage/ |
| 216 | + main.exe |
| 217 | + main.desktop |
| 218 | + package.json |
| 219 | + assets/ |
| 220 | + logo.png |
| 221 | +``` |
| 222 | + |
| 223 | +Since we support just a few locations, we could just search for the first that exists |
| 224 | +- usr |
| 225 | +- ../Resources |
| 226 | +- assets |
| 227 | +- Assets |
| 228 | +- $cwd/assets |
| 229 | + |
| 230 | +``` |
| 231 | +assets::root() -> |
| 232 | + mac -> ../Resources/ |
| 233 | + ios -> ../Resources/ |
| 234 | + android -> assets/ |
| 235 | + server -> assets/ |
| 236 | + liveview -> assets/ |
| 237 | + web -> /assets/ |
| 238 | +root().join(bundled) |
| 239 | +``` |
0 commit comments