Upload
others
View
78
Download
0
Embed Size (px)
Citation preview
Outline
Source code editor
Source code version management
Get open source code
Source code editor
vim
emacs
gedit
……
vim
A text editor is a program that can be used to
create and modify text files. One of the most
popular editors on Linux/Unix systems (it is
also available on Windows and many other
platforms) is vi. There are many variations,
with the most popular being vim.
Mode in vim
Commands in vim
Save and quit
:w, :q
Copy and paste
p v
Insert and delete
a, i, d
https://blog.interlinked.org/tutorials/vim_tutorial.html
How to use vim
Demo
More information is available online http://www.openvim.com/tutorial.html
http://vim.wikia.com/wiki/Tutorial
https://blog.interlinked.org/tutorials/vim_tutorial.html
Source code management
Git: for single project
Repo: for multiple projects
GBS: Huge project management
GIT
Git should be pronounced: /gɪt/
Git is currently the most popular implementation
of a distributed version control system.
Git originates from the Linux kernel development
and was founded in 2005 by Linus Torvalds.
Nowadays it is used by many popular open source
projects, e.g., the Android or the Eclipse developer
teams, as well as many commercial organizations.
Git: Install and Configuration
Install a git package.
$ sudo apt-get install git
Configure user information of git.
This information will be used for committer
information.
$ git config --global user.name “Your name”
$ git config --global user.email email@address
ex.
$ git config --global user.name “Sun Wukong”
$ git config --global user.email [email protected]
More configuration
vim ~/.gitconfig
Git: Key Concepts
Working directory
Source code in work
“add” command: adds
files/directories to staging area
Staging area(index)
Source code to be committed
“commit” command: makes a new
version in repository
Repository(HEAD)
Source code already committed
Files or directories are stored as
content-addressable objects
identifiable by hash value.
Working Directory
hello.c hello.h
(Local) Repository
Staging Area
Ver.1
hello.h
Ver.2
hello.c hello.h
Commit
Add
Version Management (1/2)
• Add a source code, ‘hello.cpp’
1. Add hello.c to staging area
1. $ git add hello.c
2. Make a new version
1. $ git commit -m “commit message”
• Add all of the source code
1. Add all of the source code
1. $ git add --all
2. Make a new version
1. $ git commit -m “commit message”
• Display staging area’s status
1. $ git status
Working Directory
hello.c hello.h
(Local) Repository
Staging Area
Ver.1
hello.h
Ver.2
hello.c hello.h
Commit
Add
Version Management (2/2)
Display the commit log
1. $ git log
Each commit’s hash value, author
information, date, message
commit 783c82ff64eda9f03401834de906eca77d01f691
Author: Gyeonghwan Hong <[email protected]>
Date: Mon Sep 22 10:37:44 2014 +0900
2nd version commit: hello.c is added
commit 712943bb31bf85430e1a027abe197e5b88a26110
Author: Gyeonghwan Hong <[email protected]>
Date: Thu Aug 28 12:08:17 2014 +0900
1st version commit: hello.h is added
• Return to a previous version1. git checkout <commit’s hash value>
Working Directory
hello.c hello.h
(Local) Repository
Staging Area
Ver.1
hello.h
Ver.2
hello.c hello.h
Commit
Add
– ex. git checkout 712943bb31bf85430e1a027abe197e5b88a26110
Local & Remote Repository (1/2)
“Commit”
Make a new version on local repository
“Push”
Upload commits in local repository to remote repository
• “Pull”– Download commits in
remote repository to local repository
Local PC
Working Directory
hello.c hello.h
(Local) Repository
Staging Area
Ver.1
hello.h
Ver.2
hello.c hello.h
Github Server (Remote)
(Remote) Repository
Ver.1
hello.h
Ver.2
hello.c hello.h
Pull
Push
Commit
Add
Local & Remote Repository (2/2)
• Upload to remote repository
1. $ git push <remote name> <remote branch>
– ex. $ git push origin master
Local PC
Working Directory
hello.c hello.h
(Local) Repository
Staging Area
Ver.1
hello.h
Ver.2
hello.c hello.h
Github Server (Remote)
(Remote) Repository
Ver.1
hello.h
Ver.2
hello.c hello.h
Pull
Push
Commit
Add
• Download from remote repository
1. $ git pull
Branch Management (1/3)
• Check the branch list of local repository
1. $ git branch --list
• Check the branch list of remote repository
1. $ git branch --remote* master
feature_x
• Move to another branch1. $ git checkout <branch name>
– ex. $ git checkout feature_x
Branch Management (2/3)
• Develop a new feature by making a new branch
1. Make a new branch ‘feature_x’
1. $ git branch feature_x
2. $ git checkout feature_x
2. Edit and commit source code
3. Merge ‘feature_x’ branch to original branch
1. $ git checkout master
2. $ git merge feature_x
Branch Management (3/3)
• Conflict
– When merging feature_y branch to master branch, ‘hello.h’ in version 2-x
and 2-y have different changes each other.
– This situation is called as ‘conflict’.
– The conflict should be resolved by ‘conflict resolution’ process.
1. $ git mergetool
• http://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-
and-Merging
Repo: Install and Configuration
1. Download repo.
1. $ sudo apt-get install curl
2. $ mkdir -p ~/bin
3. $ curl
"http://android.git.linaro.org/gitweb?p=tools/repo.git;a=blob_plain;f=repo;h
b=refs/heads/stable" > ~/bin/repo
4. $ chmod +x ~/bin/repo
2. Add repo’s path to the basic path list.
1. Edit ~/.bashrc
1. $ gedit ~/.bashrc
2. After adding below code to the last line, restart your shell.
PATH=~/bin:${PATH}
~/.bashrc
Register a Tizen developer ID
You should have an access right to review server
for accessing Tizen source code.
4. Register a Tizen developer ID
1. Go to https://developer.tizen.org/
2. You can log in Tizen review server (review.tizen.org).
Review Server: Configuration
1. $ gedit ~/.ssh/config
–Enter your username.
Host tizen Hostname review.tizen.org IdentityFile ~/.ssh/id_rsa User usernamePort 29418
Host review.tizen.orgHostname review.tizen.org IdentityFile ~/.ssh/id_rsa User usernamePort 29418
~/.ssh/config
Review Server: Configuration (Cont’d)
2. Run “ssh-keygen” on a shell.
1. $ ssh-keygen
– Press enter about every question for using default values.
– In result, id_rsa, id_rsa.pub files will be created.
» id_rsa: private key
» id_rsa.pub: public key
Review Server: Configuration (Cont’d)
3. After log in review.tizen.org, go to ‘settings’ menu.
4.Enter into “SSH Public Keys” menu → Press “Add Key …” button.
Review Server: Configuration (Cont’d)
5. Display the contents of public key file.
5. $ cat ~/.ssh/id_rsa.pub
6. Copy the displayed text to below text box.
Contents of ‘~/.ssh/id_rsa.pub’
Review Server: Configuration (Cont’d)
7. Test ssh server connection
1. $ ssh tizen
2. $ ssh review.tizen.org
If the connection is successful, below message will be
displayed.
How to Clone Existing Repository (1/2)
1. Log in Tizen review server (review.tizen.org)
2. Enter into “Projects” → “List”
3. Find a repository that you want to clone
Be careful: Packages in Tizen 2.2 and 3.0 are managed in different
way, so multiple packages will be displayed on the result.
4. Clone the repository
1. $ git clone
ssh://[email protected]:29
418/project-name
How to Clone Existing Repository (2/2)
• Tizen package repository has several branches by release
version.
5. Check branches
1. $ git branch --remote
• ex. origin/1.0_post
origin/2.0alpha
origin/HEAD -> origin/master
origin/master
origin/tizen_2.0
origin/tizen_2.1
origin/tizen_2.2
origin/tizen_2.3
6. Change branch to target release version
1. $ git checkout <target branch>
• ex. git checkout origin/tizen_2.2
Clone Pre-built Toolchain Packages
• Tizen source code is built by pre-built toolchains.
(Cross Compiler)
1. Clone ARM toolchain
1. $ git clone ssh://[email protected]:29418/pre-
built/toolchain-arm pre-built/toolchain-arm
2. $ cd pre-built/toolchain-arm
3. $ git checkout origin/tizen_2.2
4. $ cd -
2. Clone x86 toolchain
1. $ git clone ssh://[email protected]:29418/ pre-
built/toolchain-x86 pre-built/toolchain-x86
2. $ git pre-built/toolchain-x86
3. $ git checkout origin/tizen_2.2
4. $ cd -
Acknowledgement
This project is partially sponsored by Tianjin Samsung
Electronics Co., Ltd.
Special thanks to SKKU Embedded Software Laboratory. This
material is based on the lecture provided by them, and the
credit goes to the original authors.