Although it is possible to install software on the lab machines to do the labs in this course, I expect many of you will want to install the tools on your own machine instead. The steps below assume you are setting up the tools on your own system.
Download and install a Git client. I recommend GitHub Desktop. This client is specialized for working with repositories on GitHub. Create an account on GitHub (if you don't already have one), either on the GitHub web page, or through GitHub Desktop.
In GitHub Desktop use the 'File > Clone Repository' menu item to clone my Ada Tutorial repository to your machine. You can use 'pchapin/tutorialada' as the repository name (under the URL tab of the clone repository dialog box).
This will create a folder named 'tutorialada' under your 'Documents\GitHub' folder. This folder contains a copy of the repository and all its history. I will likely make changes to this repository as the semester unfolds. You will be able to easily get my changes by doing a 'pull' on the repository using GitHub Desktop.
In general, it is good practice to do your work in a "branch" of the repository that is local to your machine. That way any changes to the files I make will not interfere with ("conflict" with) the changes you make to the files; the branches can coexist on your machine, although only one of them will be visible at a time.
In GitHub Desktop use the 'Branch > New Branch' menu item to create a new branch. I recommend using the name 'lab-01'. You may find it useful to create separate branches for each lab. Note that when you create a branch it will be based on (branched from) the currently selected branch (master). That is, the branch will start as a copy of master at that moment.
GitHub Desktop will automatically switch to the new branch (no files will change since the new branch is a copy of the original at first). It will also invite you to publish the branch to GitHub. SAY NO! You want this branch to be entirely local on your machine. You won't be able to publish it anyway because you don't have sufficient access rights to the repository on the server.
Download GNAT Community 2021 from AdaCore's website. Double check to make sure you are downloading the right version for your platform and that it is the 2021 edition (which is the latest). When you run the installer be sure to right-click on the file and select "Run as Administrator." You'll need to log out and log back in for the installation to be fully complete.
In Windows Explorer go into the samples folder of the repository (you can open a window on the repository from GitHub Desktop by typing 'Ctrl+Shift+F'). Double-click on the file samples.gpr. This is the "GNAT project file" for the samples. The GNATstudio development environment should start and automatically load the project.
If you see a message about not being able to locate the git executable, you can ignore it. GNATstudio detects that the file is part of a Git repository and wants to use its built-in Git integration, but can't find the git program it needs to do so. You can do all your Git operations in GitHub Desktop.
In the project window in GNATstudio, expand the folder labelled with a single dot. This is the folder containing the files in the root of the project. Double-click on hello.adb to load it into the editor. This is a simple program that displays a greeting message on the console. Use the 'Build > Check Semantic' menu item in GNATstudio to check the program for semantic errors and verify that it is legal Ada.
Use the 'Build > Project > samples > hello.adb' menu item to compile the Hello program. Use the 'Build > Run > samples > hello' menu item to run the executable file.
To get a feeling for what GNAT's error messages look like, edit the Hello program to remove the text Ada.Text_IO. from in front of the call to Put_Line (be sure to remove the dot also). Try to compile the program again. You should get an error about how Put_Line is not visible. Although that procedure has been declared in package Ada.Text_IO, it is not visible despite the 'with' of that package.
Let's fix the above error a different way. Just after the 'with' statement, add a line that says use Ada.Text_IO; (be sure to include the semicolon). The 'use' statement makes the names in a package directly visible so they don't need qualification when they are used. The program should compile and run normally again.
Return to GitHub Desktop and notice that it shows you the changes you've made relative to when you created the branch. In the lower left corner of the GitHub Destkop window you should see a box labeled "Description." In that box type a description for this change. Something like "Added a use statement to the Hello program." might be appropriate. This description becomes part of the repository's history; you are able to view change descriptions for all changes that have ever been committed.
Next, click on the "Commit to lab-01" button to commit this change to your local branch. This has no effect on your master branch nor on the repository on GitHub. After doing the commit, you will see a message about there being "no local changes." This is because you have not made any changes relative to your last commit (i.e., the one you just made).
Still in GitHub Desktop, change back to the master branch (use the big button near the top of the window, in the center). Now, switch back to GNATstudio. You should see a message about how hello.adb has been changed on disk. Tell GNATstudio to reload the file. What are you are seeing is the state of the file in the master branch, which you did not change. Thus, this is the original file. You can switch back to your lab-01 branch to see your changes. You can also make another branch, e.g., lab-02 and change things in a completely different direction in that branch.
I recommend you create a separate branch for every assignment, leaving master as "read-only." You can return to any branch by just switching to it in GitHub Desktop.
There is nothing to submit for this lab. This lab is intended to just build the skills you need for later assignments. If you go through these steps in good faith I'll give you 10/10 points for the lab. Enjoy the course!
Last Revised: 2022-01-16
© Copyright 2022 by Peter C. Chapin <pchapin@vtc.edu>