From 1a88bebf828382452e2b21212b880d0c7caefcb6 Mon Sep 17 00:00:00 2001 From: Paul Mathieu Date: Sat, 7 May 2022 11:33:45 -0700 Subject: [PATCH] tools: remove hardcoded references to paths --- tools/as.py | 4 +++- tools/cc.py | 4 +++- tools/ld.py | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/as.py b/tools/as.py index 72abbf2..3cc60b0 100644 --- a/tools/as.py +++ b/tools/as.py @@ -1,12 +1,14 @@ import argparse import enum import lark +import os import struct import sys import obj_pb2 -GRAMMAR_FILE = '/home/paulmathieu/vhdl/tools/as.ebnf' +_HERE = os.path.dirname(__file__) +GRAMMAR_FILE = os.path.join(_HERE, 'as.ebnf') opcodes = { 'nop' : lambda: '0000', diff --git a/tools/cc.py b/tools/cc.py index be0579f..47261de 100644 --- a/tools/cc.py +++ b/tools/cc.py @@ -6,6 +6,7 @@ from dataclasses import dataclass import importlib import inspect import io +import os import re import struct import subprocess @@ -15,7 +16,8 @@ import lark asmod = importlib.import_module("as") -GRAMMAR_FILE = '/home/paulmathieu/vhdl/tools/cc.ebnf' +_HERE = os.path.dirname(__file__) +GRAMMAR_FILE = os.path.join(_HERE, 'cc.ebnf') CPP = ('cpp', '-P') diff --git a/tools/ld.py b/tools/ld.py index 7d9b2f4..e87f824 100644 --- a/tools/ld.py +++ b/tools/ld.py @@ -1,11 +1,13 @@ import argparse +import os import string import struct import sys import obj_pb2 -CRT0_FILE = '/home/paulmathieu/vhdl/tools/crt0.o' +_HERE = os.path.dirname(__file__) +CRT0_FILE = os.path.join(_HERE, 'ctr0.o') def parse_objs(objs):