pypowersim_wrapper_common.h: Home path no longer hard-coded.
authorAndrey Miroshnikov <andrey@technepisteme.xyz>
Sun, 10 Sep 2023 17:59:10 +0000 (17:59 +0000)
committerAndrey Miroshnikov <andrey@technepisteme.xyz>
Sun, 10 Sep 2023 17:59:10 +0000 (17:59 +0000)
chacha20/Makefile: Create bin dir if doesn't exist.

crypto/chacha20/Makefile
media/pypowersim_wrapper/pypowersim_wrapper_common.h

index 0598b1cd9aa93a2d91ab677bbb79b0ae5cd4f4a0..fa320be99069c4c8129500e6178a0197c41e3f77 100644 (file)
@@ -34,7 +34,10 @@ $(BINDIR)/%.bin: $(BINDIR)/%.elf
        $(CROSSOBJCOPY) -I elf64-little -O binary $< $@
 
 .PHONY: all clean remove
-all: ${TARGET}
+all: ${BINDIR} ${TARGET}
+
+$(BINDIR):
+       mkdir -p ${BINDIR}
 
 $(TARGET): $(OBJECTS) $(SVP64OBJECTS) $(ELFFILES) $(BINFILES)
        $(CC) -o $@ $(OBJECTS) $(LDFLAGS)
index e32c1eb595eff148eef0c89ac10c591d00b79479..0eaa861c9c6112676869ffa2f7ab850a91c7610d 100644 (file)
@@ -1,6 +1,8 @@
 #include <Python.h>
 #include <stdint.h>
 #include <stdio.h>
+#include <pwd.h>
+#include <string.h>
 
 static const char* PLUGIN_NAME = "pypowersim";
 static int python_initialized = 0;
@@ -39,8 +41,15 @@ static pypowersim_state_t *pypowersim_prepare(void) {
       // Initialize Python C API
       Py_Initialize();
 
+      // To construct directory based on username, need $HOME
+      char homeIsaDir[100];
+      const char *homeDir = getenv("HOME"); // user specific - /home/[USER NAME]
+      strcat(homeIsaDir, homeDir);
+      strcat(homeIsaDir, "/src/openpower-isa/src/openpower/decoder/isa/");
+      printf(homeIsaDir);
+
       PyObject* sysPath = PySys_GetObject((char*)"path");
-      PyObject* curDir = PyUnicode_FromString("/home/markos/src/openpower-isa/src/openpower/decoder/isa/");
+      PyObject* curDir = PyUnicode_FromString(homeIsaDir);
       PyList_Append(sysPath, curDir);
       Py_DECREF(curDir);