mirror of
https://github.com/thepigeongenerator/sdl_template.git
synced 2025-12-17 05:55:47 +01:00
update template
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,2 +1,4 @@
|
|||||||
.vscode
|
.vscode/*
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
build
|
build
|
||||||
31
.vscode/launch.json
vendored
Normal file
31
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "(gdb) C Launch",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/build/linux-86_64/${workspaceFolderBasename}",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"miDebuggerPath": "/usr/bin/gdb",
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Set Disassembly Flavor to Intel",
|
||||||
|
"text": "-gdb-set disassembly-flavor intel",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preLaunchTask": "build linux86_64"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
62
.vscode/tasks.json
vendored
Normal file
62
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "shell",
|
||||||
|
"label": "build linux86_64",
|
||||||
|
"command": "./build.sh",
|
||||||
|
"args": [
|
||||||
|
"linux86_64"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"detail": "builds the program for linux x86_64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "shell",
|
||||||
|
"label": "build win86_64",
|
||||||
|
"command": "./build.sh",
|
||||||
|
"args": [
|
||||||
|
"win86_64"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": false
|
||||||
|
},
|
||||||
|
"detail": "builds the program for windows x86_64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "shell",
|
||||||
|
"label": "build web",
|
||||||
|
"command": "./build.sh",
|
||||||
|
"args": [
|
||||||
|
"web"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": false
|
||||||
|
},
|
||||||
|
"detail": "builds the program for web using emscripten"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": "2.0.0"
|
||||||
|
}
|
||||||
22
build.sh
22
build.sh
@@ -26,7 +26,7 @@ args_win86-64()
|
|||||||
args_emscripten()
|
args_emscripten()
|
||||||
{
|
{
|
||||||
ARCHITECTURE="web"
|
ARCHITECTURE="web"
|
||||||
COMPILER="/home/user/.local/bin/emcc"
|
COMPILER="emcc" # just make sure it's in $PATH (it's a pain to install)
|
||||||
ARGS="-s USE_SDL=2"
|
ARGS="-s USE_SDL=2"
|
||||||
FILE_EXSTENSION=".html"
|
FILE_EXSTENSION=".html"
|
||||||
}
|
}
|
||||||
@@ -35,37 +35,37 @@ args_emscripten()
|
|||||||
if [ "$1" = "linux86_64" ]; then args_linux86_64
|
if [ "$1" = "linux86_64" ]; then args_linux86_64
|
||||||
elif [ "$1" = "win86_64" ]; then args_win86-64
|
elif [ "$1" = "win86_64" ]; then args_win86-64
|
||||||
elif [ "$1" = "web" ]; then args_emscripten
|
elif [ "$1" = "web" ]; then args_emscripten
|
||||||
else echo -e "\033[91mdidn't include any arguments! D:\033[0m" && exit -1
|
else echo -e "\033[91mdidn't include any arguments! D:\033[0m" && exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check whether $BUILD_DIR or $ARCHITECTURE isn't set
|
# check whether $BUILD_DIR or $ARCHITECTURE isn't set
|
||||||
if [[ -z $BUILD_DIR ]] || [[ -z "$ARCHITECTURE" ]]; then
|
if [[ -z $BUILD_DIR ]] || [[ -z "$ARCHITECTURE" ]]; then
|
||||||
echo -e "\033[91mBUILD_DIR or ARCHITECTURE not set D:\033[0m"
|
echo -e "\033[91mBUILD_DIR or ARCHITECTURE not set D:\033[0m"
|
||||||
exit -1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# make (and clear) the build directory
|
# make (and clear) the build directory
|
||||||
mkdir $BUILD_DIR $BUILD_DIR/$ARCHITECTURE
|
mkdir -p "$BUILD_DIR/$ARCHITECTURE"
|
||||||
rm -rf $BUILD_DIR/$ARCHITECTURE/*
|
rm -rf "${BUILD_DIR:?}/$ARCHITECTURE/*"
|
||||||
|
|
||||||
# copy included files or directories to the build directory
|
# copy included files or directories to the build directory
|
||||||
if [[ ! -z $INCLUDE_IN_BUILD ]]; then
|
if [[ -n $INCLUDE_IN_BUILD ]]; then
|
||||||
cp -r $INCLUDE_IN_BUILD $BUILD_DIR/$ARCHITECTURE
|
cp -r "$INCLUDE_IN_BUILD" "$BUILD_DIR/$ARCHITECTURE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# get the executable path
|
# get the executable path
|
||||||
EXE_PATH=$BUILD_DIR/$ARCHITECTURE/$PROJECT_NAME$FILE_EXSTENSION
|
EXE_PATH=$BUILD_DIR/$ARCHITECTURE/$PROJECT_NAME$FILE_EXSTENSION
|
||||||
echo "building at: $EXE_PATH"
|
echo "building at: $EXE_PATH"
|
||||||
|
|
||||||
# check whether the compiler path contains an executable at said path
|
# check whether the compiler can actually be executed
|
||||||
if [ ! -x $COMPILER ]; then
|
if [ ! -x "$COMPILER" ] && ! command -v "$COMPILER" > /dev/null; then
|
||||||
echo -e "\033[91mCouldn't find an executable at path: \033[0m $COMPILER"
|
echo -e "\033[91mCouldn't find an executable at path: \033[0m $COMPILER"
|
||||||
exit -1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# compile the code
|
# compile the code
|
||||||
COMMAND="$COMPILER `find ./src -name *.c` -o $EXE_PATH -Wall -g -lm $ARGS"
|
COMMAND="$COMPILER $(find ./src -name "*.c") -o $EXE_PATH -Wall -g -lm $ARGS"
|
||||||
echo "using command: $COMMAND"
|
echo "using command: $COMMAND"
|
||||||
$COMMAND
|
$COMMAND
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
Reference in New Issue
Block a user