========================================================================== Section 1 Notes ========================================================================== - 1. Linux - 2. Git - 3. Compilation -------------------------------------------------------------------------- 1. Linux -------------------------------------------------------------------------- * Options for using ecelinux machines - directly use workstations in 314 Phillips Linux Lab - log in remotely from 318 Phillips Windows Lab - log in remotely from your own laptop * Logging into ecelinux % ssh -X cb535@ecelinux-01.ece.cornell.edu % ssh -X cb535@ecelinux-02.ece.cornell.edu * Setup Script % source setup-ece2400.sh * Working at the command line % echo "Hello, World" % man echo % echo "Computer Systems Programming" > ece2400-sec1.txt % cat ece2400-sec1.txt % less ece2400-sec1.txt % ls % rm ece2400-sec1.txt % pwd % mkdir ece2400 % cd ece2400 % wget http://www.csl.cornell.edu/courses/ece2400/overview.txt % grep --color "programming" overview.txt * Editors % geany - file browser - tabs * Quota % quota * Trash % cd ${HOME}/tmp/misc % echo "testing" > testing.txt % trash testing.txt % ls ~/tmp/trash/ -------------------------------------------------------------------------- 2. Git -------------------------------------------------------------------------- * Create repo on GitHub - need an account on GitHuh - ece2400-sec1-linux-git - include default README.md * Clone repo % mkdir -p $HOME/ece2400 % git clone git@github.com:cbatten/ece2400-sec1-linux-git sec1 % cd sec1 * Modify the readme % echo "" >> README.md % echo "red" >> README.md % echo "green" >> README.md % echo "blue" >> README.md * Commit local changes and push to GitHub % git status % git xstatus % git add README.md % git commit -m "added some colors" % git xstatus % git push - view on GitHub - view raw file - view commit log * Collaborate with your partner - add ctorng as a collaborator - have Chris Torng add a few more colors, commit, and push - pull changes % git pull % git log % git xlog % cat README.md * Use TravisCI - lets assume we want to verify our README.md has the color red % grep "red" README.md - we want to automatically check for red on _every_ commit - turn on TravisCI - https://travis-ci.org/profile/cbatten - flip the switch - add a .travis.yml file which does our check % cat .travis.yml script: - grep red README.md % git add .travis.yml % git commit -m "add support for travis" % git push - https://travis-ci.org/cbatten/ece2400-sec1-linux-git - let's add a badge to our README using GitHub online text edit % git xpull - now let's break our "code" - remove "red" from the README.md - add/commit/push % git xstatus % git xadd % git xstatus % git commit -m "removed red" % git push - revisit travis and badge -------------------------------------------------------------------------- 3. Compilation -------------------------------------------------------------------------- * Draw diagram - source -> (preprocess,compiler,assembler,linker) -> executable - source -> (processor) -> preprocessed source code -> (compiler) -> assembly -> (assembler) -> objectfile -> (linker) -> executable * Create a simple C program $HOME/ece2400/sec1/example.c #include void main() { int a = 1; int b = 2; int c = a + b; printf("%d",c); } * Compile, assemble, link in one step % cd $HOME/ece2400/sec1 % gcc -o example example.c % ./example * Compile, assemble, link in separate steps % gcc -E -o example.i example.c % less example.i % gcc -S -o example.S example.i % less example.S % gcc -c -o example.o example.S % objdump -dC example.o % gcc -o example example.o % objdump -dC example % ./example * Add file, commit, push - only add/commit source code, never generated code % git add example.c % git commit -m "added example c program" % git push * Collaborate with your partner - have Chris Torng first pull, then edit/push example c program % git pull % gcc -o example example.c % ./example % cat example.c