Browse Source

updated makefile/tasks.json to allow relative build folders. practiced using pseudo random in main.cpp for qwixx game.

wes 4 years ago
parent
commit
d1386ef4ed
4 changed files with 24 additions and 8 deletions
  1. 5 5
      .vscode/tasks.json
  2. 3 3
      Makefile
  3. 5 0
      Qwixx/die.cpp
  4. 11 0
      Qwixx/main.cpp

+ 5 - 5
.vscode/tasks.json

@@ -13,7 +13,7 @@
         "label": "control shift B",
         "type": "shell",
         //  displays time stamp of executable in directory
-        "command": "ls ${fileBasenameNoExtension}/${fileBasenameNoExtension}.exe |tail -n3 |head -1",
+        "command": "cd ${relativeFileDirname}; ls ${fileBasenameNoExtension}/${fileBasenameNoExtension}.exe |tail -n3 |head -1",
         "dependsOn": ["default run executable"],
         "group": {"kind": "build","isDefault": true}
         },
@@ -21,25 +21,25 @@
         "label": "overwritten",
         "type": "shell",
         // delete current executable so it can be overwritten with new one
-        "command": "make clean f=${fileBasenameNoExtension}.exe",
+        "command": "make clean p=${relativeFileDirname} f=${fileBasenameNoExtension}.exe",
         "dependsOn": ["default directory"]
         },
         {
         "label": "default compile",
         "type": "shell",
-        "command": "make ${fileBasenameNoExtension}.exe",
+        "command": "make p=${relativeFileDirname} ${fileBasenameNoExtension}.exe",
         "dependsOn": ["overwritten"]
         },
         {
         "label": "default run executable",
         "type": "shell",
-        "command": "${fileBasenameNoExtension}/${fileBasenameNoExtension}.exe",
+        "command": "cd ${relativeFileDirname}; ${fileBasenameNoExtension}/${fileBasenameNoExtension}.exe",
         "dependsOn": ["default compile"]
         },
         {
         "label": "default directory",
         "windows" : {
-            "command": "$(test-path ${fileBasenameNoExtension}) -or $(mkdir ${fileBasenameNoExtension}) >$null"
+            "command": "$(cd ${relativeFileDirname}; test-path ${fileBasenameNoExtension}) -or $(mkdir ${fileBasenameNoExtension}) >$null"
             },
         "type": "shell",
         "presentation" : {

+ 3 - 3
Makefile

@@ -16,11 +16,11 @@ OUTPUT_FOLDER = $(basename $@)
 #  info : 
 #  $(foreach v, $(.VARIABLE), $(info $(v) = $($(v))))
 #  -gdwarf-2 for debug information for intel VTune Profiler.
-%.exe : %.cpp
-	g++ $< -g3 -gdwarf-4 -o $(basename $@)\$@ 
+%.exe : $(p)\%.cpp
+	g++ $< -g3 -gdwarf-4 -o $(p)\$(basename $@)\$@ 
 clean :
 #	del $(basename $(f))\$(f)
-	'$(ProgramFiles)/Git/usr/bin/rm.exe' -rf $(basename $(f))\$(f)
+	'$(ProgramFiles)/Git/usr/bin/rm.exe' -rf $(p)\$(basename $(f))\$(f)
 #  cp was not working in powershell, it has to be copy. line endings matter for some programs
 #  to remove ambiguity from the copy command, quotes are necessary to put around the destination path to specify it was a directory and not a file
 url2file.exe : url2file.c url2file/libpng16.dll url2file/libcurl.dll

+ 5 - 0
Qwixx/die.cpp

@@ -0,0 +1,5 @@
+#include <stdlib.h>
+
+int die (int a){
+    
+}

+ 11 - 0
Qwixx/main.cpp

@@ -0,0 +1,11 @@
+#include <iostream>
+#include <stdlib.h>
+#include <time.h>
+int main (){
+    fprintf (stdout,"Qwixx initiated!");
+    srand(time(NULL));
+    // print 10 random numbers - however rand in clib is pseudo random
+    for (int i = 0; i<1000; i++) {
+        std::cout << (rand() % 6) + 1 << std::endl;
+    }
+}