chore: replace '/' to os.path.join
This commit is contained in:
parent
60eba26cd4
commit
203aa39d9c
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
from typing import TextIO
|
||||
|
||||
from osdk.model import ComponentManifest, TargetManifest, Props
|
||||
|
@ -89,7 +90,7 @@ def build(componentSpec: str, targetSpec: str, props: Props = {}) -> str:
|
|||
context = contextFor(targetSpec, props)
|
||||
|
||||
shell.mkdir(context.builddir())
|
||||
ninjaPath = f"{context.builddir()}/build.ninja"
|
||||
ninjaPath = os.path.join(context.builddir(), "build.ninja")
|
||||
|
||||
with open(ninjaPath, "w") as f:
|
||||
gen(f, context)
|
||||
|
@ -124,7 +125,7 @@ def buildAll(targetSpec: str) -> Paths:
|
|||
target = context.target
|
||||
|
||||
shell.mkdir(context.builddir())
|
||||
ninjaPath = f"{context.builddir()}/build.ninja"
|
||||
ninjaPath = os.path.join(context.builddir(), "build.ninja")
|
||||
|
||||
with open(ninjaPath, "w") as f:
|
||||
gen(f, context)
|
||||
|
@ -132,7 +133,7 @@ def buildAll(targetSpec: str) -> Paths:
|
|||
shell.exec(f"ninja", "-v", "-f", ninjaPath)
|
||||
|
||||
return Paths(
|
||||
context.builddir() + "/bin",
|
||||
context.builddir() + "/lib",
|
||||
context.builddir() + "/obj",
|
||||
os.path.join(context.buildir(), "bin"),
|
||||
os.path.join(context.buildir(), "lib"),
|
||||
os.path.join(context.buildir(), "obj")
|
||||
)
|
||||
|
|
|
@ -60,7 +60,7 @@ def debugCmd(args: Args):
|
|||
|
||||
exe = builder.build(componentSpec, targetSpec)
|
||||
|
||||
shell.exec("/usr/bin/lldb", "-o", "run", exe)
|
||||
shell.exec("lldb", "-o", "run", "exe")
|
||||
|
||||
|
||||
cmds += [Cmd("d", "debug", "Debug the target", debugCmd)]
|
||||
|
@ -174,7 +174,7 @@ def installCmd(args: Args):
|
|||
for extSpec in project.extern:
|
||||
ext = project.extern[extSpec]
|
||||
|
||||
extPath = f"{const.EXTERN_DIR}/{extSpec}"
|
||||
extPath = os.path.join(const.EXTERN_DIR, extSpec)
|
||||
|
||||
if os.path.exists(extPath):
|
||||
print(f"Skipping {extSpec}, already installed")
|
||||
|
@ -214,7 +214,7 @@ def initCmd(args: Args):
|
|||
project_name = input("Project name: ")
|
||||
description = input("Description: ")
|
||||
|
||||
to_create = ["src", "meta", "meta/targets", "meta/plugins"]
|
||||
to_create = ["src", "meta", os.path.join("meta", "targets"), os.path.join("meta", "plugins")]
|
||||
|
||||
os.mkdir(project_name.lower())
|
||||
for directory in to_create:
|
||||
|
|
|
@ -5,9 +5,9 @@ VERSION = "0.4.0"
|
|||
MODULE_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
ARGV0 = os.path.basename(sys.argv[0])
|
||||
OSDK_DIR = ".osdk"
|
||||
BUILD_DIR = f"{OSDK_DIR}/build"
|
||||
CACHE_DIR = f"{OSDK_DIR}/cache"
|
||||
EXTERN_DIR = f"{OSDK_DIR}/extern"
|
||||
SRC_DIR = "src/"
|
||||
BUILD_DIR = os.path.join(OSDK_DIR, "build")
|
||||
CACHE_DIR = os.path.join(OSDK_DIR, "cache")
|
||||
EXTERN_DIR = os.path.join(OSDK_DIR, "extern")
|
||||
SRC_DIR = "src"
|
||||
META_DIR = f"meta"
|
||||
TARGETS_DIR = f"{META_DIR}/targets"
|
||||
TARGETS_DIR = os.path.join(META_DIR, "targets")
|
||||
|
|
|
@ -40,20 +40,20 @@ class ComponentInstance:
|
|||
return self.manifest.type == Type.LIB
|
||||
|
||||
def binfile(self, context: IContext) -> str:
|
||||
return f"{context.builddir()}/bin/{self.manifest.id}.out"
|
||||
return os.path.join(context.builddir(), "bin", f"{self.manifest.id}.out")
|
||||
|
||||
def objdir(self, context: IContext) -> str:
|
||||
return f"{context.builddir()}/obj/{self.manifest.id}"
|
||||
return os.path.join(context.builddir(), "obj", self.manifest.id)
|
||||
|
||||
def objsfiles(self, context: IContext) -> list[tuple[str, str]]:
|
||||
return list(
|
||||
map(
|
||||
lambda s: (
|
||||
s, f"{self.objdir(context)}/{s.replace(self.manifest.dirname() + '/', '')}.o"),
|
||||
s, os.path.join(self.objdir(context), s.replace(os.path.join(self.manifest.dirname(), ''), '') + ".o")),
|
||||
self.sources))
|
||||
|
||||
def libfile(self, context: IContext) -> str:
|
||||
return f"{context.builddir()}/lib/{self.manifest.id}.a"
|
||||
return os.path.join(context.builddir(), "lib", f"{self.manifest.id}.a")
|
||||
|
||||
def outfile(self, context: IContext) -> str:
|
||||
if self.isLib():
|
||||
|
@ -99,7 +99,7 @@ class Context(IContext):
|
|||
return utils.hash((self.target.props, str(self.tools)))[0:8]
|
||||
|
||||
def builddir(self) -> str:
|
||||
return f"{const.BUILD_DIR}/{self.target.id}-{self.hashid()[:8]}"
|
||||
return os.path.join(const.BUILD_DIR, f"{self.target.id}-{self.hashid()[:8]}")
|
||||
|
||||
|
||||
def loadAllTargets() -> list[TargetManifest]:
|
||||
|
|
|
@ -53,4 +53,4 @@ def view(context: Context, scope: str | None = None, showExe: bool = True, showD
|
|||
g.edge(req, instance.manifest.id,
|
||||
arrowhead="none", color="#aaaaaa")
|
||||
|
||||
g.view(filename=f"{context.builddir()}/graph.gv")
|
||||
g.view(filename=os.path.join(context.builddir(), "graph.gv"))
|
|
@ -1,3 +1,5 @@
|
|||
import os
|
||||
|
||||
import importlib.util as importlib
|
||||
from osdk.logger import Logger
|
||||
from osdk.shell import readdir
|
||||
|
@ -19,9 +21,9 @@ def load(path: str):
|
|||
|
||||
def loadAll():
|
||||
logger.log("Loading plugins...")
|
||||
for files in readdir("meta/plugins"):
|
||||
for files in readdir(os.path.join("meta", "plugins")):
|
||||
if files.endswith(".py"):
|
||||
plugin = load(f"meta/plugins/{files}")
|
||||
plugin = load(os.path.join("meta", "plugins", files))
|
||||
|
||||
if plugin:
|
||||
print(f"Loaded plugin {plugin.name}")
|
||||
|
|
|
@ -102,8 +102,8 @@ def wget(url: str, path: str | None = None) -> str:
|
|||
import requests
|
||||
|
||||
if path is None:
|
||||
path = const.CACHE_DIR + "/" + \
|
||||
hashlib.sha256(url.encode('utf-8')).hexdigest()
|
||||
path = os.path.join(const.CACHE_DIR,
|
||||
hashlib.sha256(url.encode('utf-8')).hexdigest())
|
||||
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
|
|
Loading…
Reference in a new issue