xref: /aosp_15_r20/tools/asuite/aidegen/README.md (revision c2e18aaa1096c836b086f94603d04f4eb9cf37f5)
1*c2e18aaaSAndroid Build Coastguard Worker# AIDEGen
2*c2e18aaaSAndroid Build Coastguard Worker
3*c2e18aaaSAndroid Build Coastguard WorkerAIDEGen aims to automate the project setup process for developers to work on
4*c2e18aaaSAndroid Build Coastguard WorkerJava or C/C++project in popular IDE environment. Developers no longer need to manually
5*c2e18aaaSAndroid Build Coastguard Workerconfigure an IntelliJ project, such as all the project dependencies. It's a
6*c2e18aaaSAndroid Build Coastguard Worker**command line tool** that offers the following features:
7*c2e18aaaSAndroid Build Coastguard Worker
8*c2e18aaaSAndroid Build Coastguard Worker*   Configure Android Studio or IntelliJ project files with the relevant module
9*c2e18aaaSAndroid Build Coastguard Worker    dependencies resolved.
10*c2e18aaaSAndroid Build Coastguard Worker
11*c2e18aaaSAndroid Build Coastguard Worker*   Launch IDE for a specified sub-project or build target, i.e. frameworks/base
12*c2e18aaaSAndroid Build Coastguard Worker    or Settings.
13*c2e18aaaSAndroid Build Coastguard Worker
14*c2e18aaaSAndroid Build Coastguard Worker*   Launch IDE for specified folder(s) which contains build targets, i.e. cts.
15*c2e18aaaSAndroid Build Coastguard Worker
16*c2e18aaaSAndroid Build Coastguard Worker*   Auto configure JDK and Android coding style for IntelliJ.
17*c2e18aaaSAndroid Build Coastguard Worker
18*c2e18aaaSAndroid Build Coastguard Worker## 1. Prerequisites:
19*c2e18aaaSAndroid Build Coastguard Worker
20*c2e18aaaSAndroid Build Coastguard Worker*   IDE installation, choose one of prefer IDE, including Android Studio,
21*c2e18aaaSAndroid Build Coastguard Worker    IntelliJ IDEA, Eclipse, CLion and VS Code.
22*c2e18aaaSAndroid Build Coastguard Worker
23*c2e18aaaSAndroid Build Coastguard Worker*   Setup Android development environment.
24*c2e18aaaSAndroid Build Coastguard Worker
25*c2e18aaaSAndroid Build Coastguard Worker```
26*c2e18aaaSAndroid Build Coastguard Worker$ source build/envsetup.sh && lunch <TARGET>
27*c2e18aaaSAndroid Build Coastguard Worker```
28*c2e18aaaSAndroid Build Coastguard Worker
29*c2e18aaaSAndroid Build Coastguard Worker## 2. Basic Usage:
30*c2e18aaaSAndroid Build Coastguard Worker
31*c2e18aaaSAndroid Build Coastguard Worker### Example 1: Launch IDE with module name
32*c2e18aaaSAndroid Build Coastguard Worker
33*c2e18aaaSAndroid Build Coastguard WorkerExample to generate and launch IntelliJ project for framework and Settings:
34*c2e18aaaSAndroid Build Coastguard Worker
35*c2e18aaaSAndroid Build Coastguard Worker```
36*c2e18aaaSAndroid Build Coastguard Worker$ aidegen Settings framework
37*c2e18aaaSAndroid Build Coastguard Worker```
38*c2e18aaaSAndroid Build Coastguard Worker
39*c2e18aaaSAndroid Build Coastguard Worker### Example 2: Launch IDE with module path
40*c2e18aaaSAndroid Build Coastguard Worker
41*c2e18aaaSAndroid Build Coastguard WorkerExample to generate and launch IntelliJ project for framework and Settings:
42*c2e18aaaSAndroid Build Coastguard Worker
43*c2e18aaaSAndroid Build Coastguard Worker```
44*c2e18aaaSAndroid Build Coastguard Worker$ aidegen packages/apps/Settings frameworks/base
45*c2e18aaaSAndroid Build Coastguard Worker```
46*c2e18aaaSAndroid Build Coastguard Worker
47*c2e18aaaSAndroid Build Coastguard Worker### Example 3: Launch IDE with build skipped
48*c2e18aaaSAndroid Build Coastguard Worker
49*c2e18aaaSAndroid Build Coastguard WorkerExample to generate and launch IntelliJ project for framework and Settings and
50*c2e18aaaSAndroid Build Coastguard Workerskip build time:
51*c2e18aaaSAndroid Build Coastguard Worker
52*c2e18aaaSAndroid Build Coastguard Worker```
53*c2e18aaaSAndroid Build Coastguard Worker$ aidegen Settings framework -s
54*c2e18aaaSAndroid Build Coastguard Worker```
55*c2e18aaaSAndroid Build Coastguard Worker
56*c2e18aaaSAndroid Build Coastguard Worker### Example 4: Launch IDE with native module
57*c2e18aaaSAndroid Build Coastguard Worker
58*c2e18aaaSAndroid Build Coastguard WorkerExample to generate and launch CLion project:
59*c2e18aaaSAndroid Build Coastguard Worker
60*c2e18aaaSAndroid Build Coastguard Worker```
61*c2e18aaaSAndroid Build Coastguard Worker$ aidegen <module> -i c
62*c2e18aaaSAndroid Build Coastguard Worker```
63*c2e18aaaSAndroid Build Coastguard WorkerThe native projects will be launched in CLion and you have to select,
64*c2e18aaaSAndroid Build Coastguard Worker**Tools > CMake > Change Project Root**
65*c2e18aaaSAndroid Build Coastguard WorkerChange project root to the source directory: the relative path which is the directory shown in CLion’s project view. For example, if frameworks/base/media is your project, please change project root directly to frameworks/base/media.
66*c2e18aaaSAndroid Build Coastguard Worker
67*c2e18aaaSAndroid Build Coastguard Worker## 3. Optional arguments:
68*c2e18aaaSAndroid Build Coastguard Worker
69*c2e18aaaSAndroid Build Coastguard WorkerDevelopers can also use the following optional arguments with AIDEGen commands.
70*c2e18aaaSAndroid Build Coastguard Worker
71*c2e18aaaSAndroid Build Coastguard Worker| Option | Long option       | Description                                                              |
72*c2e18aaaSAndroid Build Coastguard Worker|:------:|:------------------|--------------------------------------------------------------------------|
73*c2e18aaaSAndroid Build Coastguard Worker|  `-d`  | `--depth`         | The depth of module referenced by source.                                |
74*c2e18aaaSAndroid Build Coastguard Worker|  `-i`  | `--ide`           | Launch IDE type, j=IntelliJ s=Android Studio e=Eclipse c=CLion v=VS Code |
75*c2e18aaaSAndroid Build Coastguard Worker|  `-p`  | `--ide-path`      | Specify user's IDE installed path.                                       |
76*c2e18aaaSAndroid Build Coastguard Worker|  `-n`  | `--no_launch`     | Do not launch IDE.                                                       |
77*c2e18aaaSAndroid Build Coastguard Worker|  `-r`  | `--config-reset`  | Reset all AIDEGen's saved configurations.                                |
78*c2e18aaaSAndroid Build Coastguard Worker|  `-s`  | `--skip-build`    | Skip building jars or modules.                                           |
79*c2e18aaaSAndroid Build Coastguard Worker|  `-v`  | `--verbose`       | Displays DEBUG level logging.                                            |
80*c2e18aaaSAndroid Build Coastguard Worker|  `-a`  | `--android-tree`  | Generate whole Android source tree project file for IDE.                 |
81*c2e18aaaSAndroid Build Coastguard Worker|  `-e`  | `--exclude-paths` | Exclude the directories in IDE.                                          |
82*c2e18aaaSAndroid Build Coastguard Worker|  `-l`  | `--language`      | Launch IDE with a specific language,j=java c=C/C++ r=Rust                |
83*c2e18aaaSAndroid Build Coastguard Worker|  `-h`  | `--help`          | Shows help message and exits.                                            |
84*c2e18aaaSAndroid Build Coastguard Worker
85*c2e18aaaSAndroid Build Coastguard Worker## 4. Troubleshooting tips:
86*c2e18aaaSAndroid Build Coastguard Worker
87*c2e18aaaSAndroid Build Coastguard WorkerIf you get an error like: "Dependent modules dictionary is empty." or other errors, try a make
88*c2e18aaaSAndroid Build Coastguard Workerclean.
89*c2e18aaaSAndroid Build Coastguard Worker
90*c2e18aaaSAndroid Build Coastguard Worker## 5. FAQ:
91*c2e18aaaSAndroid Build Coastguard Worker
92*c2e18aaaSAndroid Build Coastguard WorkerQ1. If I already have an IDE project file, and I run command AIDEGen to generate
93*c2e18aaaSAndroid Build Coastguard Workerthe same project file again, what will happen?
94*c2e18aaaSAndroid Build Coastguard Worker
95*c2e18aaaSAndroid Build Coastguard WorkerA1: The former IDEA project file will be overwritten by the newly generated one
96*c2e18aaaSAndroid Build Coastguard Workerfrom the aidegen command.
97*c2e18aaaSAndroid Build Coastguard Worker
98*c2e18aaaSAndroid Build Coastguard WorkerQ2: When do I need to re-run AIDEGen?
99*c2e18aaaSAndroid Build Coastguard Worker
100*c2e18aaaSAndroid Build Coastguard WorkerA2: Re-run AIDEGen after repo sync.
101*c2e18aaaSAndroid Build Coastguard Worker
102*c2e18aaaSAndroid Build Coastguard Worker## 6. Hint:
103*c2e18aaaSAndroid Build Coastguard Worker
104*c2e18aaaSAndroid Build Coastguard Worker1. In IntelliJ, uses [File] > [Invalidate Caches / Restart...] to force
105*c2e18aaaSAndroid Build Coastguard Worker       project panel updated when your IDE didn't sync.
106*c2e18aaaSAndroid Build Coastguard Worker
107*c2e18aaaSAndroid Build Coastguard Worker2. If you run aidegen on a remote desktop, make sure there is no IntelliJ
108*c2e18aaaSAndroid Build Coastguard Worker       running in a different desktop session.
109*c2e18aaaSAndroid Build Coastguard Worker
110*c2e18aaaSAndroid Build Coastguard Worker## 6. Feedback:
111*c2e18aaaSAndroid Build Coastguard Worker
112*c2e18aaaSAndroid Build Coastguard WorkerIf you have any questions or feedback, contact [email protected].
113*c2e18aaaSAndroid Build Coastguard Worker
114*c2e18aaaSAndroid Build Coastguard WorkerIf you have any bugs or feature requests email them to [email protected].
115*c2e18aaaSAndroid Build Coastguard Worker
116*c2e18aaaSAndroid Build Coastguard Worker
117