add instr, manifest, dev_variant

This commit is contained in:
2026-04-10 22:24:08 +03:00
parent 522946453b
commit 6bd1943d8c
10 changed files with 291 additions and 22 deletions

View File

@@ -1,6 +1,9 @@
import sys
import csv
import json
import os
SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__))
def main():
if len(sys.argv) != 2:
@@ -11,11 +14,22 @@ def main():
with open(manifest_dir + '/dev_type', 'r') as f:
dev_type = f.read()
with open(manifest_dir + '/dev_variant', 'r') as f:
dev_variant = f.read()
try:
with open(SCRIPT_PATH + '/instructions.json', 'r') as f:
instructions = json.load(f)
except Exception as e:
print(f'unable to read instructions file: {e}')
instructions = []
mem_segments = []
out_manifest = {
'mem_segments': mem_segments,
'dev_type': dev_type
'dev_type': dev_type,
'dev_variant': dev_variant,
'instructions': instructions
}
with open(manifest_dir + '/seg_data.csv', 'r', newline='') as csvfile:

View File

@@ -17,13 +17,14 @@ int main(int argc, char** argv)
const char *dirpath = argv[1];
const char *filename = "dev_type";
char *tgtpath = (char*)calloc(strlen(dirpath) + strlen(filename) + 1, sizeof(char));
char *tgtpath = (char*)calloc(strlen(dirpath) + strlen(filename) + 2, sizeof(char));
if(tgtpath == NULL)
{
return 1;
}
sprintf(tgtpath, "%s/%s", dirpath, filename);
tgtpath[strlen(dirpath) + strlen(filename) + 1] = 0;
FILE *fptr;

View File

@@ -0,0 +1,56 @@
#include "mem.h"
#include "mem_seg.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define STR(name) XSTR(name)
#define XSTR(name) #name
#ifndef ARCH
#pragma message "ARCH not set, using empty"
#define ARCH asdf
#endif
#define __ARCH STR(ARCH)
int main(int argc, char** argv)
{
if(argc != 2)
{
printf("provide target directory\n");
return 1;
}
const char *dirpath = argv[1];
const char *filename = "dev_variant";
char *tgtpath = (char*)calloc(strlen(dirpath) + strlen(filename) + 2, sizeof(char));
if(tgtpath == NULL)
{
return 1;
}
sprintf(tgtpath, "%s/%s", dirpath, filename);
tgtpath[strlen(dirpath) + strlen(filename) + 1] = 0;
FILE *fptr;
fptr = fopen(tgtpath, "w");
if(fptr == NULL)
{
printf("errof opening file\n");
return 1;
}
char* dev_variant = STR(ARCH);
fprintf(fptr, "%s", dev_variant);
fclose(fptr);
free(tgtpath);
return 0;
}

View File

@@ -16,13 +16,14 @@ int main(int argc, char** argv)
const char *dirpath = argv[1];
const char *filename = "seg_data.csv";
char *tgtpath = (char*)calloc(strlen(dirpath) + strlen(filename) + 1, sizeof(char));
char *tgtpath = (char*)calloc(strlen(dirpath) + strlen(filename) + 2, sizeof(char));
if(tgtpath == NULL)
{
return 1;
}
sprintf(tgtpath, "%s/%s", dirpath, filename);
tgtpath[strlen(dirpath) + strlen(filename) + 1] = 0;
FILE *fptr;