Advertisement
AtomicOs

README.md

May 28th, 2021
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.80 KB | None | 0 0
  1. # Brave Browser
  2.  
  3.  
  4. ## Overview
  5.  
  6. This repository holds the build tools needed to build the Brave desktop browser for macOS, Windows, and Linux. In particular, it fetches and syncs code from the projects we define in `package.json` and `src/brave/DEPS`:
  7.  
  8. - [Chromium](https://chromium.googlesource.com/chromium/src.git)
  9. - Fetches code via `depot_tools`.
  10. - sets the branch for Chromium (ex: 65.0.3325.181).
  11. - [brave-core](https://github.com/brave/brave-core)
  12. - Mounted at `src/brave`.
  13. - Maintains patches for 3rd party Chromium code.
  14. - [adblock-rust](https://github.com/brave/adblock-rust)
  15. - Implements Brave's ad-block engine.
  16. - Linked through [brave/adblock-rust-ffi](https://github.com/brave/brave-core/tree/master/components/adblock_rust_ffi).
  17.  
  18. ## Downloads
  19.  
  20. You can [visit our website](https://brave.com/download) to get the latest stable release.
  21.  
  22. ## Other repositories
  23.  
  24. For other versions of our browser, please see:
  25.  
  26. * iOS - [brave/brave-ios](https://github.com/brave/brave-ios)
  27.  
  28. ## Contributing
  29.  
  30. Please see the [contributing guidelines](./CONTRIBUTING.md).
  31.  
  32. ## Community
  33.  
  34. [Join the Q&A community](https://community.brave.com/) if you'd like to get more involved with Brave. You can [ask for help](https://community.brave.com/c/support-and-troubleshooting),
  35. [discuss features you'd like to see](https://community.brave.com/c/brave-feature-requests), and a lot more. We'd love to have your help so that we can continue improving Brave.
  36.  
  37. Help us translate Brave to your language by submitting translations at https://www.transifex.com/brave/brave/.
  38.  
  39. Follow [@brave](https://twitter.com/brave) on Twitter for important news and announcements.
  40.  
  41. ## Install prerequisites
  42.  
  43. Follow the instructions for your platform:
  44.  
  45. - [macOS](https://github.com/brave/brave-browser/wiki/macOS-Development-Environment)
  46. - [Windows](https://github.com/brave/brave-browser/wiki/Windows-Development-Environment)
  47. - [Linux/Android](https://github.com/brave/brave-browser/wiki/Linux-Development-Environment)
  48.  
  49. ## Clone and initialize the repo
  50.  
  51. Once you have the prerequisites installed, you can get the code and initialize the build environment.
  52.  
  53. ```bash
  54. git clone git@github.com:brave/brave-browser.git
  55. cd brave-browser
  56. npm install
  57.  
  58. # this takes 30-45 minutes to run
  59. # the Chromium source is downloaded which has a large history
  60. npm run init
  61. ```
  62. brave-core based android builds should use `npm run init -- --target_os=android --target_arch=arm` (or whatever cpu type you want to build for)
  63.  
  64. You can also set the target_os and target_arch for init and build using
  65.  
  66. ```
  67. npm config set target_os android
  68. npm config set target_arch arm
  69. ```
  70.  
  71. ## Build Brave
  72. The default build type is component.
  73.  
  74. ```
  75. # start the component build compile
  76. npm run build
  77. ```
  78.  
  79. To do a release build:
  80.  
  81. ```
  82. # start the release compile
  83. npm run build Release
  84. ```
  85.  
  86. brave-core based android builds should use `npm run build -- --target_os=android --target_arch=arm` or set the npm config variables as specified above for `init`
  87.  
  88. ### Build Configurations
  89.  
  90. Running a release build with `npm run build Release` can be very slow and use a lot of RAM especially on Linux with the Gold LLVM plugin.
  91.  
  92. To run a statically linked build (takes longer to build, but starts faster)
  93.  
  94. ```bash
  95. npm run build -- Static
  96. ```
  97.  
  98. To run a debug build (Component build with is_debug=true)
  99.  
  100. ```bash
  101. npm run build -- Debug
  102. ```
  103.  
  104. You may also want to try [[using sccache|sccache-for-faster-builds]].
  105.  
  106. ## Run Brave
  107. To start the build:
  108.  
  109. `npm start [Release|Component|Static|Debug]`
  110.  
  111. # Update Brave
  112.  
  113. `npm run sync -- [--force] [--init] [--create] [brave_core_ref]`
  114.  
  115. **This will attempt to stash your local changes in brave-core, but it's safer to commit local changes before running this**
  116.  
  117. `npm run sync` will (depending on the below flags):
  118.  
  119. 1. 📥 Update sub-projects (chromium, brave-core) to latest commit of a git ref (e.g. tag or branch)
  120. 2. 🤕 Apply patches
  121. 3. 🔄 Update gclient DEPS dependencies
  122. 4. ⏩ Run hooks (e.g. to perform `npm install` on child projects)
  123.  
  124. | flag | Description |
  125. |---|---|
  126. |`[no flags]`|updates chromium if needed and re-applies patches. If the chromium version did not change it will only re-apply patches that have changed. Will update child dependencies **only if any project needed updating during this script run** <br> **Use this if you want the script to manage keeping you up to date instead of pulling or switching branch manually. **|
  127. |`--create`|when used with `brave_core_ref` it will create a branch if one does not already exist|
  128. |`--force`|updates both _Chromium_ and _brave-core_ to the latest remote commit for the current brave-core branch and the _Chromium_ ref specified in brave-browser/package.json (e.g. `master` or `74.0.0.103`). Will re-apply all patches. Will force update all child dependencies <br> **Use this if you're having trouble and want to force the branches back to a known state. **|
  129. |`--init`|force update both _Chromium_ and _brave-core_ to the versions specified in brave-browser/package.json and force updates all dependent repos - same as `npm run init`|
  130.  
  131.  
  132. Run `npm run sync brave_core_ref` to checkout the specified _brave-core_ ref and update all dependent repos including chromium if needed
  133.  
  134. ### Scenarios
  135.  
  136. #### Create a new branch
  137. ```bash
  138. brave-core> git checkout -b branch_name
  139. ```
  140.  
  141. or
  142.  
  143. ```bash
  144. brave-browser> npm run sync -- --create branch_name
  145. ```
  146.  
  147. ### Checkout an existing branch or tag
  148. ```bash
  149. brave-core> git fetch origin
  150. brave-core> git checkout [-b] branch_name
  151. brave-core> npm run sync
  152. ...Updating 2 patches...
  153. ...Updating child dependencies...
  154. ...Running hooks...
  155. ```
  156.  
  157. or
  158.  
  159. ```bash
  160. brave-browser> npm run sync --create branch_name
  161. ...Updating 2 patches...
  162. ...Updating child dependencies...
  163. ...Running hooks...
  164. ```
  165.  
  166. ### Update the current branch to latest remote
  167. ```bash
  168. brave-core> git pull
  169. brave-core> npm run sync
  170. ...Updating 2 patches...
  171. ...Updating child dependencies...
  172. ...Running hooks...
  173. ```
  174.  
  175. #### Reset to latest brave-browser master, brave-core master and chromium
  176. ```bash
  177. brave-browser> git checkout master
  178. brave-browser> git pull
  179. brave-browser> npm run sync -- --init
  180. ```
  181.  
  182. #### When you know that DEPS didn't change, but .patch files did (quickest)
  183. ```bash
  184. brave-core> git checkout featureB
  185. brave-core> git pull
  186. brave-browser> npm run apply_patches
  187. ...Applying 2 patches...
  188. ```
  189.  
  190. # Enabling third-party APIs:
  191.  
  192. 1. **Google Safe Browsing**: Get an API key with SafeBrowsing API enabled from https://console.developers.google.com/. Update the `GOOGLE_API_KEY` environment variable with your key as per https://www.chromium.org/developers/how-tos/api-keys to enable Google SafeBrowsing.
  193.  
  194. # Troubleshooting
  195.  
  196. See [Troubleshooting](https://github.com/brave/brave-browser/wiki/Troubleshooting) for solutions to common problems.
  197.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement