Add assignment bootstrap script
parent
73317be9c9
commit
4cee90ee25
|
|
@ -0,0 +1,71 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 [-b|--build] [-m|--make] <new-project-name>"
|
||||||
|
echo
|
||||||
|
echo "Options:"
|
||||||
|
echo " -m, --make After cmake, run 'make' inside the build directory (requires make)"
|
||||||
|
echo " -h, --help Show this help"
|
||||||
|
echo
|
||||||
|
echo "Example: $0 -b my_project"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
DO_MAKE=0
|
||||||
|
|
||||||
|
while [[ ${1:-} == -* ]]; do
|
||||||
|
case "$1" in
|
||||||
|
-m|--make) DO_MAKE=1; shift ;;
|
||||||
|
-h|--help) usage ;;
|
||||||
|
--) shift; break ;;
|
||||||
|
*) echo "Unknown option: $1" >&2; usage ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $# -ne 1 ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
raw_name="$1"
|
||||||
|
name="${raw_name#@}"
|
||||||
|
src="as_template"
|
||||||
|
dest="${name}"
|
||||||
|
|
||||||
|
if [ -e "$dest" ]; then
|
||||||
|
echo "Error: destination '$dest' already exists" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$0: COPY: $src -> $dest..."
|
||||||
|
cp -a -- "$src" "$dest"
|
||||||
|
|
||||||
|
echo "$0: MOVE: $src/as_template.cpp -> $dest/${name}.cpp..."
|
||||||
|
mv "$dest/as_template.cpp" "$dest/${name}.cpp"
|
||||||
|
|
||||||
|
echo "$0: REPLACE: 'as_template' -> '$name' in all files in $dest..."
|
||||||
|
sed -i "s/as_template/${name}/g" "$dest"/*
|
||||||
|
|
||||||
|
echo "Preparing build directory and running cmake..."
|
||||||
|
|
||||||
|
cd "$dest" && mkdir -p build && cd build && cmake ..
|
||||||
|
echo "CMake finished (see $dest/build)."
|
||||||
|
|
||||||
|
if [ "$DO_MAKE" -eq 1 ]; then
|
||||||
|
echo "Make option enabled. Building with make..."
|
||||||
|
|
||||||
|
if command -v nproc >/dev/null 2>&1; then
|
||||||
|
NPROCS=$(nproc)
|
||||||
|
elif getconf _NPROCESSORS_ONLN >/dev/null 2>&1; then
|
||||||
|
NPROCS=$(getconf _NPROCESSORS_ONLN)
|
||||||
|
else
|
||||||
|
NPROCS=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
make -j"$NPROCS"
|
||||||
|
echo "Make finished."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Created new assignment '$dest'."
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
cmake_minimum_required(VERSION 3.18)
|
||||||
|
project(as_template CXX)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
|
# adding this option to make clangd work
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
add_subdirectory(../raylib-cpp raylib)
|
||||||
|
|
||||||
|
add_executable(as_template as_template.cpp)
|
||||||
|
target_link_libraries(as_template PUBLIC raylib raylib_cpp)
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
# Building and Running
|
||||||
|
|
||||||
|
Clone the repository, navigate to the root of the project, and initialize the
|
||||||
|
submodules:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone https://github.com/humanoidsandvichdispenser/cs381.git
|
||||||
|
cd cs381
|
||||||
|
git submodule update --init --recursive
|
||||||
|
```
|
||||||
|
|
||||||
|
Navigate to the `as_template` directory, create a build directory, and run CMake to
|
||||||
|
generate the build files:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd as_template
|
||||||
|
mkdir -p build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
```
|
||||||
|
|
||||||
|
Compile the code using `make`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
This should create an executable named `as_template` in the `build` directory. You can
|
||||||
|
run the executable with the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./as_template
|
||||||
|
```
|
||||||
|
|
||||||
|
# Instructions on how to use the program
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
#include "Color.hpp"
|
||||||
|
#include "raylib.h"
|
||||||
|
#include <raylib-cpp.hpp>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
raylib::Window window(800, 600, "CS381 - Assignment 0");
|
||||||
|
window.SetState(FLAG_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
|
window.SetTargetFPS(60); // save cpu cycles
|
||||||
|
|
||||||
|
while (!window.ShouldClose()) {
|
||||||
|
window.BeginDrawing();
|
||||||
|
|
||||||
|
window.ClearBackground(raylib::Color::RayWhite());
|
||||||
|
|
||||||
|
window.EndDrawing();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue