Lesson 2: Preparing the Development Environment

Overview

 * How to import ElastosRDKforUbuntu and Elastos Source Code
 * Setting up the Compile Environment
 * How to start the emulator
 * How to start an adb shell

Quick Tutorial
Import ElastosRDKforUbuntu

Set the local destination for ElastosRDKforUbuntu

Delete the readme in the Sources directory
 * Delete the readme.txt found in ~/ElastosRDKforUbuntu/Sources.



Import Elastos

Set the local destination for Elastos
 * Set the Elastos local destination to ~/ElastosRDKforUbuntu/Sources.
 * When it is finished, you will see:



Run Setup.sh
 * Run the setup.sh script. You can find it in ~/ElastosRDKforUbuntu/Setup.


 * Shortcuts on your desktop.


 * Arm Android: Elastos RDK Development Environment for Android app.
 * Gcc Devtools: Elastos RDK Development Environment for C/C++ app.



Build Elastos code in the sources folder
 * Open the RDK box by double clicking the shortcut of Arm Android, and run emake.



Change to the Targets directory
 * Change to the Targets directory by running the pd @ command after emake.



Start the emulator and eldrop
 * a. Run emu -c to start the emulator.
 * b. Run eldrop to push Elastos object files to the device.



Emulator

Start adb shell
 * Run elrsh to open the adb shell window.



Exercise: Build and Run TextViewDemo

 * a. Change the current directory to /data/data/com.elastos.runtime/elastos
 * b. Run ./superexe -app TextViewDemo to launch the TextViewDemo sample.



All the windows

TextViewDemo in the emulator

Branches
Git allows you to create branches, e.g. independent copies of the source code which can be changed independently from each other. The default branch is called master. '
 * git branch
 * This command lists all locally available branches. The currently active branch is marked with *.


 * git branch -a
 * If you want to see all branches (including remote branches), use this command.


 * git branch testing
 * Create a new branch.

 Syntax: git branch 
 * in the above is optional
 * if not specified the last commit will be used
 * If specified the corresponding commit will be used


 * git checkout testing
 * Switch to your new branch


 * git branch -d testing
 * Delete a branch which is not needed anymore.

If you want to check if branch has been deleted,use git branch command.

Pull changes
Pull allows you to get the latest changes from another repository. In your second repository, make some changes, push them to your remote repository and pull these changes to your first repository. cd ~
 * 1) Switch to home

cd ~/repo02 echo "A change" > test01 git commit -a -m "A change" git push origin cd ~/repo01 git pull ../remote-repository.git/ less test01
 * 1) Switch to second directory
 * 1) Make changes
 * 1) Commit
 * 1) Push changes to remote repository
 * 2) Origin is automatically maintained as we cloned from this repository
 * 1) Switch to the first repository and pull in the changes
 * 1) Check the changes

Push a branch to remote repository
By default Git will only push matching branches to a remote repository. That means that you have to manually push a new branch once. Afterwards "git push" will also push the new branch. git push origin testing
 * 1) Push testing branch to remote repository

git checkout testing
 * 1) Switch to the testing branch

echo "News for you" > test01 git commit -a -m "new feature in branch"
 * 1) Some changes

git push This way you can decided which branches should be visible to other repositories and which should be local branches.
 * 1) Push all including branch

Merging
Merge allows you to combine the changes of two branches. Merge performs a so-called three-way-merge between the latest snapshot of two branches, based on the most recent common ancestor of both.

As a result, you have a new snapshot. You can merge changes from one branch to the current active one via the following command.

Syntax: git merge 

git merge testing 

If a merge conflict occurs Git will mark the conflict in the file and the programmer has to resolve the conflict manually. After resolving it, he can add the file to the staging index and commit the change.

Committing

 * git commit -m "Initial commit"
 * Make a commit of your file to the local repository with message.


 * git add . && git commit -m "the commit message"
 * Add the changes to the index and commit


 * git commit -a -m "These are new changes"
 * Commit the changes,-a will commit changes for modified files, but will not add automatically new files.


 * git commit --amend -m "More changes - now correct"
 * Correction of commit messages - git amend

Revert a commit
git revert commit_name If you deleted a file but you have not yet added it to the index or committed the change, you can check out the file again. rm test01 git checkout test01 If you added a file to the index but do not want to commit the file, you can remove it from the index via the git reset file command. // Create a file touch incorrect.txt // Accidently add it to the index git add. // Remove it from the index git reset incorrect.txt // Delete the file rm incorrect.txt If you deleted a directory and you have not yet committed the changes, you can restore the directory via the following command:
 * 1) Delete a file
 * 1) Revert the deletion

git checkout HEAD -- your_dir_to_restore

Create or Delete files
Create a file and put it under version control
 * git add.
 * Add all (files and directories) to the Git repository

touch nonsense.txt git add. && git commit -m "a new file has been created"

echo "Cool new feature in this branch" > test01 git commit -a -m "new feature" git checkout master cat test01
 * 1) Some changes
 * 1) Switch to the master branch
 * 1) Check that the content of test01 is the old one

Delete a file and commit If you delete a file which is under version control git add .will not pick this file up. You need to use the git commit command with the -a flag or the -A flag in the git add command.

rm nonsense.txt git add. && git commit -m "a new file has been created" git commit -a -m "File nonsense.txt is now removed" git add -A. git commit -m "File nonsense.txt is now removed"
 * 1) Remove the file
 * 1) Try standard way of committing -> will not work
 * 1) Now commit with the -a flag
 * 1) Alternatively you could add deleted files to the staging index via

Revert Changes
If you create files in your working copy which you do not want to commit, you can discard them. touch test04 echo "this is trash" > test04
 * 1) Create a new file with content

git clean -n
 * 1) Make a dry-run to see what would happen
 * 2) -n is the same as --dry-run

git clean -f You can check out older revisions of your source code via the commit ID. The commit ID is shown if you enter the git log command. It is displayed behind the commit word. cd ~/repo01 git log
 * 1) Now delete
 * 1) Switch to home
 * 1) Get the log

git checkout commit_name
 * 1) Copy one of the older commits and checkout the older revision via

If you have not added the changes to the staging index, you can also revert the changes directly. echo "nonsense change" > test01 git checkout test01 cat test01 echo "another nonsense change" > test01 git add test01 git reset HEAD test01 git checkout test01
 * 1) Some nonsense change
 * 1) Not added to the staging index. Therefore we can
 * 2) just checkout the old version
 * 1) Check the result
 * 1) Another nonsense change
 * 1) We add the file to the staging index
 * 1) Restore the file in the staging index
 * 1) Get the old version from the staging index

Push changes to another repository
Make some changes and push them from your first repository to the remote repository via the following commands. cd ~/repo01
 * 1) Make some changes in the first repository

echo "Hello, hello. Turn your radio on" > test01 echo "Bye, bye. Turn your radio off" > test02
 * 1) Make some changes in the file

git commit -a -m "Some changes"
 * 1) Commit the changes, -a will commit changes for modified files
 * 2) but will not add automatically new files

git push ../remote-repository.git
 * 1) Push the changes

Show Log and Status

 * git log
 * Show the log file.Show the history of commits in the current branch


 * git diff
 * Check the changes via the diff command. Show the differences between the uncommitted files,and the last commit in the current branch.


 * git status
 * See the current status of your repository (which files are changed / new / deleted)


 * gitk --all
 * This starts a nice graphical view of the changes

Frequently-used Command List
git branch

git branch mytopic

git checkout master

git checkout mytopic

git commit -m "my massage."

git pull

git pull --rebase

git rebase master

git rebase --continue

git merge mytopic

git push

-->

Back