Hello Project
COP-3402
Overview
In this project you will create a "hello, world!\n" program. It might sound easy, but the catch is you will need to create it using the command-line development workflow shown in class that we'll be using for all projects in the class, including the editor (vim or emacs), build system (make), and version control (git) for submission.
Creating the "hello, world!\n" program with vim or emacs
Using either vim or emacs in eustis, record yourself using script
(see instructions below) writing, compiling, and running a hello world program in C, i.e., a program that uses printf to write "hello, world!\n" to the console.
ssh into eustis, replacing
NID
with your UCF NID.ssh NID@eustis.eecs.ucf.edu
Create and enter a directory for your program.
mkdir hello; cd hello
Be sure you are emitting "hello, world!\n".
Start recording:
script -T hello.timing hello.script
Use vim or emacs to create a hello world program called
hello.c
, then compile it and run it.emacs hello.c
or
vim hello.c
Stop recording.
exit
or Ctrl-D on an empty command prompt.
Self-check
You can verify on your own that your recording works by replaying it yourself:
scriptreplay hello.timing hello.script 2
The 2
is optional and will replay it at 2x
speed. You can use a higher number as well to replay faster. Use Ctrl-C to stop playback.
Creating a Makefile
Review resources for writing Makefiles:
- 21st Century C, Chapter 1, pg 17
- An Introduction to Makefiles
Then create a Makefile for your project:
- In your
hello/
folder, create and edit a file calledMakefile
in emacs or vim. - Write a Makefile that will build your "hello, world!\n" program when running
make
. - Add a
clean
target that will remove the generated program, but not the source code!
Tips
- Makefile targets must use tab indentation not spaces
- The first target in the file is the default run by
make
- Use .PHONY targets when the target is not a real file
Self-check
The following sequence should delete, rebuild, and run your "hello, world!\n" program.
make clean make ./hello
Submitting your program via git
Review resources for using git:
- 21st Century C, Chapter 4
- Pro Git
Configure git with your name, UCF email, and editor (emacs or vim), for example (substituting your own information):
git config --global user.name "John Doe" git config --global user.email johndoe@example.com git config --global core.editor emacs
Create your repo and submit your project:
In your
hello/
folder, create the repo. Only do this once for the entire project.git init
- Create a
.gitignore
file to tell git to ignore generated files and commit it as well.- Use
git status
to confirm that files have either been committed or ignore.
- Use
Use
git add
andgit commit
to add all the necessary files to your repo.Files to add:
.gitignore
hello.c
Makefile
hello.timing
hello.script
Do not use
git add .
orgit commit -a
orgit commit -m
. Instead, list explicitly the names of the files togit add
and write the commit message in your editor when it pops up.You can use
ls -a
to show hidden files, which have a.
as their first character, like.gitignore
. They will not show up by default withls
.To make sure only the necessary files are submitted (and not binaries), add the names of the binary file(s) to
.gitignore
(one per line). For emacs users, you can also add*~
(asterisk tilde) to the .gitignore to ignore emacs backup files.Add the URL of your personal remote repository, replacing
NID
with your UCF NID.git remote add submission gitolite3@eustis3.eecs.ucf.edu:cop3402/NID/hello
Synchronize your local repo with the remote eustis3 repo.
git push --set-upstream submission master
Note that
--set-upstream
only needs to used for the first push. Subsequent pushes can be done with justgit push
.
Self-check
git status
shows nothing.- All generated files are in
.gitignore
. Clone, build, and run the program in a separate directory, for instance (replacing NID with your UCF NID).
# go to home directory cd ~ # make a fresh clone, give any new directory name git clone gitolite3@eustis3.eecs.ucf.edu:cop3402/NID/hello hello_new # enter the fresh clone's directory (whatever you put as the directory name above) cd hello_new # double-check that only the five required files are submitted ls -a # you should see your five files, plus ~.git~, ~.~, and ~..~ # make sure make works correctly (and builds the ~hello~ program) make # make sure ~hello~ runs correctly (it should output ~hello, world!~ on its own line) ./hello # make sure ~make clean~ works (it should remove the any binaries, like ~hello~) make clean # make sure ~make~ and ~./hello~ still work after clean make ./hello # make sure .gitignore is setup properly and ~hello~ is not listed as untracked git status # make sure your terminal recording works scriptreplay hello.timing hello.script 2 # double-check that only the five required files are submitted another way git ls-tree --full-tree -r --name-only HEAD
Troubleshooting
If you make a mistake in typing the URL, you can remove the submission remote and try the add step again:
git remote rm submission git remote add submission gitolite3@eustis3.eecs.ucf.edu:cop3402/NID/hello # replace NID with yours
- Do not try creating a new repo if you make a mistake. You will not be able to push the new repo to gitolite3, since there already is one there. You can always make new changes and commit them to fix mistakes.
- If in self-check hello_new already exists, just use a fresh directory name.
If you add a file that you do not want in the repo, e.g., the
hello
program binary, then you can remove it withgit rm hello git commit # enter the commit message git push # to record the change in the remote grading repo
Grading schema
Criterion | Points |
---|---|
The git repo exists | 1 |
The repo contains only the required five files | 1 |
.gitignore works correctly | 1 |
The replay shows using vim or emacs to code | 1 |
The Makefile works correctly | 1 |
The program runs correctly | 1 |
TOTAL | 6 |