GitHub/git +GitHub/git +
CMake +CMake +
CLionCLion
GitGit
25.04.17 Igor Khokhriakov 3
Git
“Git was created by Linus Torvalds in 2005 for
development of the Linux kernel, with other kernel
developers contributing to its initial development.”
Wikipedia.org
According to StackOverflow survey 2017 ~70% of
developers are using git
25.04.17 Igor Khokhriakov 4
Key points about Git
● Strong support for non-linear development
– a core assumption is that a change will be merged more
often than it is written
● Distributed development
– Git gives each developer a local copy of the full
development history
● Efficient handling of large projects
– an order of magnitude faster than some version control
systems
GitHubGitHub
25.04.17 Igor Khokhriakov 6
GitHub
● Hosting that provides git service
● Suddenly became a central feature in git
ecosystem
– My personal experience is that back in 2012 they
did not have even in-line commit comment (vs
bitbucket)
25.04.17 Igor Khokhriakov 7
Summary
SourceForge/svn = GitHub/git
aka Hosting/repository
SourceForge/svn ≠ GitHub/git
GitHub provides tons of features and
integrations: travis, appveyor, read-the-
docs, ...
PRACTICEPRACTICE
25.04.17 Igor Khokhriakov 9
Git concept
● Simple case: one user; direct access to the remote repo
– Create new file:
25.04.17 Igor Khokhriakov 10
Git concept
– Working with branches:
● $> git branch my_branch
● $> git checkout my_branch
– Shortcut: git checkout -b my_branch
● Do stuff
● $> git push -u my_branch origin
– Merging branch into the master
● $> git checkout master
● $> git merge my_branch
25.04.17 Igor Khokhriakov 11
Git cheat sheet
http://files.zeroturnaround.com/pdf/zt_git_cheat_sheet.pdf
GitHub/git workflowGitHub/git workflow
25.04.17 Igor Khokhriakov 13
GitHub concept
● Contributing via Pull-Request (PR)
25.04.17 Igor Khokhriakov 14
GitHub concept
– Creating a Pull-Request
● GitHub fork
● $> git clone …
● $> git checkout -b feature
● Do stuff
● $> git push
● GitHub create a Pull-Request
● Do more pushes
25.04.17 Igor Khokhriakov 15
GitHub concept
– Rebasing onto master
● $> git pull –rebase upstream master
● $> git push
– Closing the PR
● maintainer(s) approval(s) + tests passed
● GitHub megre PR
● $> git branch -d feature
● Sync fork master (origin) with upstream master
– $> git checkout master; git pull upstream master
25.04.17 Igor Khokhriakov 16
gitk
25.04.17 Igor Khokhriakov 17
https://www.atlassian.com/git/tutorials
25.04.17 Igor Khokhriakov 18
Keep in mind
● Git is very powerful and flexible
– github.com/tango-controls/cppTango
● Merged 4 repositories
● Preserved commits history
● Preserved branches
Do not hesitate to google the
most astounding ideas
aka How can I do X in git
CMakeCMake
25.04.17 Igor Khokhriakov 20
CMake
● Cross-platform build automatization tool
● Declarative scripting language for managing
native projects
● Dependency management (via pkg-config or
cmake modules)
● Testing
● Packaging
25.04.17 Igor Khokhriakov 21
CmakeLists.txt
25.04.17 Igor Khokhriakov 22
Build using cmake
● $> mkdir build
● $> cd build
● $> cmake ..
● $> make
● $> make install
… better use IDE like CLion
25.04.17 Igor Khokhriakov 23
CMake guide lines
● Use the following directory structure:
– configure
– include
– docs
– src
– test
● Use dedicated project when configuration is totally different
from the root project
25.04.17 Igor Khokhriakov 24
CMake guide lines
● Split complex project into modules
– add_library(my_module OBJECT …)
● Use CTest for integration testing. Unit tests
must be independent
● Use CPack to generate packages and custom
targets to deploy them
– add_custom_target(COMMAND curl ...)
25.04.17 Igor Khokhriakov 25
Where get help?
● No good book :(
● Find some open-source project and explore it
– https://github.com/pni-libraries/libpnicore
– https://github.com/ufo-kit/ufo-core
● CMake itself... for gurus
CLionCLion
25.04.17 Igor Khokhriakov 27
25.04.17 Igor Khokhriakov 28
Agenda
● CMake support
● Navigation
● Refactoring
● Git integration
● Debugging
● Creating live templates
25.04.17 Igor Khokhriakov 29
CMake support
File → settings
OR
ctrl+alt+s
25.04.17 Igor Khokhriakov 30
CMake support
● Run targets
25.04.17 Igor Khokhriakov 31
Navigation
● Find class: ctrl+n
● Find file: ctrl+shift+n
● Subclasses:
● Implementation
&Override:
25.04.17 Igor Khokhriakov 32
Navigation
● Method lookup: ctrl+F12 OR structure tab
● Code navigation: ctrl+click on an item
● Find usages: Alt+F7
25.04.17 Igor Khokhriakov 33
Refactoring
● Rename: shift+F6
● Change signature: ctrl+F6
● Move entity: F6
● Generate definitions: ctrl+shift+d
● Generate … : alt+insert
● Generate constructor
that matches super
25.04.17 Igor Khokhriakov 34
Refactoring
● Extract method: highlight and ctrl+alt+m
● Extract variable: highlight and ctrl+alt+v
● Extract …: Refactoring → Extract
– Constant
– Parameter
– Define
– Typedef
– Superclass
– Subclass
25.04.17 Igor Khokhriakov 35
Git integration
● Compare with branch...
● Make pull request
● Resolve conflicts
● Rebase
● Etc: VCS → Git; context menu → Git
● Local changes&history:
25.04.17 Igor Khokhriakov 36
Debugging
25.04.17 Igor Khokhriakov 37
Live template creation
25.04.17 Igor Khokhriakov 38
https://www.jetbrains.com/help/clion/2017.1/reference.html
Live coding!Live coding!
Questions?Questions?
Thank you!!!Thank you!!!

GitHub/git+Cmake+Clion

  • 1.
    GitHub/git +GitHub/git + CMake+CMake + CLionCLion
  • 2.
  • 3.
    25.04.17 Igor Khokhriakov3 Git “Git was created by Linus Torvalds in 2005 for development of the Linux kernel, with other kernel developers contributing to its initial development.” Wikipedia.org According to StackOverflow survey 2017 ~70% of developers are using git
  • 4.
    25.04.17 Igor Khokhriakov4 Key points about Git ● Strong support for non-linear development – a core assumption is that a change will be merged more often than it is written ● Distributed development – Git gives each developer a local copy of the full development history ● Efficient handling of large projects – an order of magnitude faster than some version control systems
  • 5.
  • 6.
    25.04.17 Igor Khokhriakov6 GitHub ● Hosting that provides git service ● Suddenly became a central feature in git ecosystem – My personal experience is that back in 2012 they did not have even in-line commit comment (vs bitbucket)
  • 7.
    25.04.17 Igor Khokhriakov7 Summary SourceForge/svn = GitHub/git aka Hosting/repository SourceForge/svn ≠ GitHub/git GitHub provides tons of features and integrations: travis, appveyor, read-the- docs, ...
  • 8.
  • 9.
    25.04.17 Igor Khokhriakov9 Git concept ● Simple case: one user; direct access to the remote repo – Create new file:
  • 10.
    25.04.17 Igor Khokhriakov10 Git concept – Working with branches: ● $> git branch my_branch ● $> git checkout my_branch – Shortcut: git checkout -b my_branch ● Do stuff ● $> git push -u my_branch origin – Merging branch into the master ● $> git checkout master ● $> git merge my_branch
  • 11.
    25.04.17 Igor Khokhriakov11 Git cheat sheet http://files.zeroturnaround.com/pdf/zt_git_cheat_sheet.pdf
  • 12.
  • 13.
    25.04.17 Igor Khokhriakov13 GitHub concept ● Contributing via Pull-Request (PR)
  • 14.
    25.04.17 Igor Khokhriakov14 GitHub concept – Creating a Pull-Request ● GitHub fork ● $> git clone … ● $> git checkout -b feature ● Do stuff ● $> git push ● GitHub create a Pull-Request ● Do more pushes
  • 15.
    25.04.17 Igor Khokhriakov15 GitHub concept – Rebasing onto master ● $> git pull –rebase upstream master ● $> git push – Closing the PR ● maintainer(s) approval(s) + tests passed ● GitHub megre PR ● $> git branch -d feature ● Sync fork master (origin) with upstream master – $> git checkout master; git pull upstream master
  • 16.
  • 17.
    25.04.17 Igor Khokhriakov17 https://www.atlassian.com/git/tutorials
  • 18.
    25.04.17 Igor Khokhriakov18 Keep in mind ● Git is very powerful and flexible – github.com/tango-controls/cppTango ● Merged 4 repositories ● Preserved commits history ● Preserved branches Do not hesitate to google the most astounding ideas aka How can I do X in git
  • 19.
  • 20.
    25.04.17 Igor Khokhriakov20 CMake ● Cross-platform build automatization tool ● Declarative scripting language for managing native projects ● Dependency management (via pkg-config or cmake modules) ● Testing ● Packaging
  • 21.
    25.04.17 Igor Khokhriakov21 CmakeLists.txt
  • 22.
    25.04.17 Igor Khokhriakov22 Build using cmake ● $> mkdir build ● $> cd build ● $> cmake .. ● $> make ● $> make install … better use IDE like CLion
  • 23.
    25.04.17 Igor Khokhriakov23 CMake guide lines ● Use the following directory structure: – configure – include – docs – src – test ● Use dedicated project when configuration is totally different from the root project
  • 24.
    25.04.17 Igor Khokhriakov24 CMake guide lines ● Split complex project into modules – add_library(my_module OBJECT …) ● Use CTest for integration testing. Unit tests must be independent ● Use CPack to generate packages and custom targets to deploy them – add_custom_target(COMMAND curl ...)
  • 25.
    25.04.17 Igor Khokhriakov25 Where get help? ● No good book :( ● Find some open-source project and explore it – https://github.com/pni-libraries/libpnicore – https://github.com/ufo-kit/ufo-core ● CMake itself... for gurus
  • 26.
  • 27.
  • 28.
    25.04.17 Igor Khokhriakov28 Agenda ● CMake support ● Navigation ● Refactoring ● Git integration ● Debugging ● Creating live templates
  • 29.
    25.04.17 Igor Khokhriakov29 CMake support File → settings OR ctrl+alt+s
  • 30.
    25.04.17 Igor Khokhriakov30 CMake support ● Run targets
  • 31.
    25.04.17 Igor Khokhriakov31 Navigation ● Find class: ctrl+n ● Find file: ctrl+shift+n ● Subclasses: ● Implementation &Override:
  • 32.
    25.04.17 Igor Khokhriakov32 Navigation ● Method lookup: ctrl+F12 OR structure tab ● Code navigation: ctrl+click on an item ● Find usages: Alt+F7
  • 33.
    25.04.17 Igor Khokhriakov33 Refactoring ● Rename: shift+F6 ● Change signature: ctrl+F6 ● Move entity: F6 ● Generate definitions: ctrl+shift+d ● Generate … : alt+insert ● Generate constructor that matches super
  • 34.
    25.04.17 Igor Khokhriakov34 Refactoring ● Extract method: highlight and ctrl+alt+m ● Extract variable: highlight and ctrl+alt+v ● Extract …: Refactoring → Extract – Constant – Parameter – Define – Typedef – Superclass – Subclass
  • 35.
    25.04.17 Igor Khokhriakov35 Git integration ● Compare with branch... ● Make pull request ● Resolve conflicts ● Rebase ● Etc: VCS → Git; context menu → Git ● Local changes&history:
  • 36.
  • 37.
    25.04.17 Igor Khokhriakov37 Live template creation
  • 38.
    25.04.17 Igor Khokhriakov38 https://www.jetbrains.com/help/clion/2017.1/reference.html
  • 39.
  • 40.
  • 41.

Editor's Notes

  • #10 $> git init $> git pull === $> git fetch & git merge $> git remote -v
  • #14 Switch to browser
  • #24 cppTango test/test_suite is a dedicated project
  • #38 Live template variables: https://www.jetbrains.com/help/clion/2017.1/creating-and-editing-template-variables.html