The process documented here is for making a change to a single project (aka git repo).
But the change I have (implement a single new piece of functionality) spans multiple projects, is it possible to create a single patch to do this or does this need to be broken up into seperate interdependant patches?
I think you should divide your patch into patches for each project. Here is the logic why I think this. Each Android project has it's own .git directory, i.e. these projects are in separate git repositories. Repo tool is just an addition over git commands, i.e. it does not provide you with new functionality. Thus, you cannot create a patch that will span across the projects (because they are not connected). Therefore, you need to divide your patch into separate patches for each AOSP project that is affected by your new functionality.
To create a project wide diff, use this command:
repo diff > /path/to/store/patch/all-changes.diff
Next, one can also use repo forall -p -c git status to check the status of each project.
repo forall -p -c git diff will show diff for each project.
Even I am trying to figure out how to generate patches for individual projects. However, if you understand the AOSP source, all the projects are coming from aosp_root/.repo/manifests/default.xml
If you try something like repo forall -p -c git diff > /path/to/patch/change.diff, this file will contain all the patches. I still haven't figured out how to extract the -p part, which prints the project name (Usually is a relative path inside the aosp_root), and convert it into a patch name.
However, these things are really not hard to in a bash environment with some scripting. Heck, I think repo is also open source, meaning you could even modify it youself!
If you take a look at this manifest, you should notice that the projects are interpreted same way as git repo projects which are easy to clone and reproduce the patches for. Though very similar to git, AOSP folder structure varies from device to device, SOM to SOM. It makes it a little harder to actually create individual projects due to path and other dissimilarities.
One thing that I am familiar with is using a tool like splitpatch on linux machines to split out the patches. However, this tool like others, will find splitting AOSP patches since many files have the same name, for example, if you change Android.mk across multiple projects, the patch splitter finds it hard to understand this structure, so it thinks that the same file was modified over and over.
If you refer the AOSP documentation, for anything, you'll find a good amount of information. Now you will need to use non-traditional search techniques to actually find most of them. The AOSP Documentation that Google provides on the web is not sufficient to understand everything. It's just a starting point.
The actual documentation is found inside the specific project. If you look at the Readme files under that project, or the docs/ folder, then you might find something more relevant.
It's easy to say that it's not well documented, but actually the problem is in exposure and organization. Documentation is available abundantly, finding it often is the problem.
Related
I have an Android project composed of AOSP, and other code in an Ubuntu environment. As you know, I used git and its associated tool repo to download AOSP according to the procedures on android source site. Now I want to have a way of controlling the changes I make to the environment. I have read about Git, but perhaps not enough to know what is the best way to do this. Maybe I already have this capability just by using Git locally? So my question is: What is the best way to save state in my build environment please, and how do I save this on Github as a remote backup repository? I believe I need to have a .gitignor file to exclude object files? Basically I have a WORKING_DIRECTORY with all of my code in there. That directory has a .repo and .git directory in it.
You will find that most or all of your changes will be under certain branches. For me, I develop roms for the Nexus 9 so a lot of my changes are under device/htc/flounder. The common branch is frameworks/base/ where I also make a lot of changes.
To this end I have two separate git repos that store these:
https://github.com/seanashmore/frameworks_base
https://github.com/seanashmore/device_htc_flounder
To create these, I created a github account. Then went to each of he top level folders i.e. frameworks/base and device/htc/flounder and ran the command 'git init'. This initializes those directories as git repositories. You also need to create the repos on your github account, this will give you url's for you to 'push' your code to.
The initial push of frameworks/base will take some time as it is quite large, but once you have done that first push its very handy to keep track of your code changes and all the other benefits that git brings.
A very handy git guide can be found here: http://rogerdudler.github.io/git-guide/
If you need any more information or help just ask.
We all know that How much the Backup of the project is vital in the programming, when specially you are making a major changes in your code to experiment something new. But eventually you came across to fact that last changes that you have made earlier were correct. Or sometimes you just messed up your whole project. So there must be Backup of project for that.
So Do you know a way to take a local backup into other location of your machine as we know mySql , Visual studio do. I know only a single way and that is to just copy the project from project explorer and and past it some where else.
Do you know any other way of taking such type of back up. (I do not want to take back up over the internet. Thanks)
Android studio is powered by Intellij and it has inbuilt support for Local History.
Local History, which is your personal real-time version control
system. Local History is independent of external version control
systems and works with the directories of your project even when they
are not under any VCS control.
Local history is cleared when you install a new version of IntelliJ
IDEA or when you invalidate caches. Therefore, check in the changes to
your version control system before performing these operations.
Source - official IntlliJ documentation
Detailed description of Local Hostory feature here
Local History is independent of external version control systems and
works with the directories of your project even when they are not
under any VCS control. It applies to any structural artifacts: a
project, a directory or package, a file, a class, class members, tags,
or selected fragment of text.
Unlike usual version control systems, Local History is intended for
your personal use, it does not support shared access.
With Local History, IntelliJ IDEA automatically tracks changes you
make to the source code, results of refactoring, and state of the
source code based on a set of predefined events (testing, deployment,
commit or update).
Local History revisions are marked with labels, which are similar to
versions in traditional version control systems. Labels based on
predefined events are added to the local revisions automatically;
besides that, you can put your own labels to the project artifacts to
mark your changes. Reverting or viewing differences are performed
against these labels.
As showed in the comments, you can use git local. Once started git in your repository you can make all the changes and commits, create branches, tags and everything useful to control the versions of your application.
More info see: Git Basics - Getting a Git Repository
One way how you can take backup of all the code is using GIT as mentioned above,
in one more answer, I found these steps very useful -
it will generate a zip file of the project resources -
git init # on the root of the project folder
git add . # note: android studio already created .gitignore
git commit -m 'ready to zip sources'
git archive HEAD --format=zip > d:/archive.zip
Note: If you intend to send this by email, you have to remove gradlew.bat from zip file.
Reference answer
From experience, GitHub has been the best option. But remember, saving code only is not the safest way. Never forget your Keystore!!! Without it, you can never update a package on the store, you will lose all billing licenses and Firebase tools...the list is endless.
In short, GitHub your code, and manually back up that keystore file.
Suppose i'm working on a regular xCode project that has git tracking the files.
For internal usage purposes, i'd like to know (by looking inside at the iOS app running on the iphone) certain debugging information, such as what git branch the developer was on.
how could this be done?
on Android, you can modify the build script to look at the person's .git directory from where they've built and see something like refs/heads/feature_branch_2 inside the /.git/HEAD file.
on xCode i have no idea what tool is even being used to build, let alone modify the build script. or... do i have to modify the build script? (i.e. is there an easier way?)
You can manage it via source tree MAC application and change gitignore path for manage conflict.
You can change gitignore path - SourceTree->Preferences->Git->Global Ignore List->Edit File.
You can manage various commits and all the thing via its GUI.
I am trying to get a specific package (Launcher2) from the google git repo and compile it. Planning on changing a few things and create a custom one.
After installing git i used this to get the source from the tag of the 2.2 sdk:
git clone https://android.googlesource.com/platform/packages/apps/Launcher2 launcher2
git checkout android-sdk-2.2_r2
After all done and the files exist, I am creating a new android project in eclipse and choosing the 2.2 target framework and marking the "use existing source". The project is opening but with many compilation errors like invalid imports and unrecognized fields and so on ...
It looks like the source I have does not match the framework.
What am I missing?
if you want to compile in Eclipse, you will not be able.
Because it uses internal classes (com.android.internal.*) and private APIs.
See Launcher 1 (until android 2.1) : http://code.google.com/p/android-launcher-for-sdk/
Otherwise, you can have a look on the source code of ADW Launcher 2 which is based on Launcher2. You will see the modification made to be compliant with the public APIs
Ahhh... But you do know if you have the entire repo and the device tree in place, that you can build just one package. Assume for a moment, that your environment is Linux based and that your device handset is a Samsung i9000 (Galaxy S), then in your source tree you would have device/samsung/galaxys, which contains proprietary libraries and extra code related only specifically to the hardware for the Samsung i9000.
Then its a matter of having to do this as a once-off operation -
. build/envsetup.sh
lunch
Pick Samsung Galaxy s from the lunch menu. This is the tricky bit in ensuring your device handset appears on the lunch menu!
make -jX
(Replace X with the appropriate number of cores your processor has)
Your entire system.img/boot.img would be deposited in out/target/product/samsung/galaxys after a couple of hours depending on how fast your machine/environment is.
Now, to build one package you simply enter this:
make Launcher2
Now you will have a new android app called Launcher.apk that will be deposited in out/target/product/samsung/galaxys/system/app directory.
How?
Simple, when after doing a 'lunch', and invoke this command
make modules > modules_list.txt
The resulting output will contain the names of modules in that file modules_list.txt, that can be built on the command line - modules in the context of the entire AOSP source tree, it can be a (static|shared) library, native executable or even Android Java app.
Now, do not bother cleaning out the entire out/ tree (even though that can swallow up a lot of space), leave that in there to speed up the build process of individual modules.
If you really really want to delete them, issue this:
make clean && make clobber
and the entire out/ directory is removed and gone for good.
When I wanted to get Android source code, I knew that I have to use "repo". So what is repo? Why do they use repo and not just use GIT?, and is there a GUI for repo that enables me to pause/resume syncing, because every time I get disconnected occasionally it seems that repo starts syncing from the beginning!
As is mentioned in the android webpage, repo does not replace git. It is just a tool over git and helps you to manage multiple git repositories.
For example, suppose I have a big project which has a lot of features and I have several teams working on each feature and I created one repository for each feature. For example suppose my repositories are wifi, telephony, power management, etc. This action has sense when your features have different life cycles. For example if I won't touch the wifi feature in my next release and but I will modify all the rest. So under this scenario, my project or product is distributed in several different git repositories.
So, to get a centralized photo of my project (one specific moment of my project, for example a milestone), I need to get the revision (git hash or tag) of each repository. Remember that we have one repository for each feature. Manually I could do it but could be very painful. So, with repo you can have one MANIFEST which links to all the revisions of each git repo (one for each feature) and have an specific picture of my whole project.
Simply, I could say that is a way to manage centralized multiple git repositories which are decentralized.
With repo you have more features, not only to checkout at a specific point. For more info go to http://source.android.com/source/using-repo.html.
Repo and git - what they are, what they are for - is explained on source.android.com
To work with the Android code, you
will need to use both Git and Repo.
Git is an open-source version-control system designed to
handle very large projects that are
distributed over multiple
repositories. In the context of
Android, we use Git for local
operations such as local branching,
commits, diffs, and edits.
Repo is a tool that we built on top of Git. Repo helps us manage the
many Git repositories, does the
uploads to our revision control
system, and automates parts of the
Android development workflow. Repo is
not meant to replace Git, only to make
it easier to work with Git in the
context of Android. The repo command
is an executable Python script that
you can put anywhere in your path.
There's no GUI for Repo, as far as I can tell, but there's quite a bit of guidance on the site above for controlling what Repo is doing from the command line.
Concerning the pause and restart point, whilst in a terminal window doing a repo sync you can hit, "ctrl + z" to pause the repo sync. To restart simply type "fg" into the same window.
Go to:
http://source.android.com/source/git-repo.html
and you can download the repo script. It is a Python script that uses the git command to do distributed source code revision.
After you have executed repo sync, do a ps -auwf to see the processes:
For mine I saw:
\_ python -E /sde3/root/download/android/android/.repo/repo/main.py --rep
\_ git fetch korg
\_ git fetch korg
\_ git index-pack --stdin -v --fix-thin --keep=fetch-pack 5227 on
Yes, repo sync breaks often. But it is robust, just restart the command and it will resuming syncing again - those that have been updated will not be re-applied, so it will skip over them and continue with the rest.
repo sync has various useful options:
-f recovers from disconnects
-c just uploads the branch you asked for
-j <#CPUS> speeds up the sync by increasing the number of cpus used by the command