added the ability to install libs written in comet

also made it so you don't have to build comet to install the headers
This commit is contained in:
2026-07-04 19:31:25 +10:00
parent a3cafef15f
commit 672b919071
4 changed files with 41 additions and 26 deletions

View File

@@ -19,6 +19,10 @@ neb install packageName@1.0.0
(replace the number with the version number of the package you want to install)
## Changelog
### 1.2.0
- Add support for modules written in Comet
- Made it so C headers needed to install C libs are installed for the user and not system wide
### 1.1.0
- Switched from getting the latest commit of packages to getting the latest release
- Added the `uninstall` subcommand

View File

@@ -90,27 +90,37 @@ def install(args):
print_error_message(f"Failed to install [b]{name}[/]: failed to read \"rock.json\" file: {e}")
sys.exit(1)
# build source code
rock_info = data.get("rock", {})
out_path = os.path.join(comet_libs_dir, f"{name}.cometlib")
try:
os.chdir(temp_dir)
os.chdir(temp_dir)
if rock_info.get("nativeComet") == True:
console.print(["cp"] + glob.glob("src/*", recursive=True) + [comet_libs_dir, "-r"])
subprocess.run(
["gcc"] + glob.glob("src/*.c", recursive=True) + ["-fPIC", "-shared", "-Wl,-undefined,symbol_lookup", "-o", out_path] + rock_info.get("gccArgs", []),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
["cp"] + glob.glob("src/*", recursive=True) + [comet_libs_dir, "-r"],
check=True
)
except KeyError as e:
print_error_message(f"Failed to install [b]{name}[/]: \"rock.json\" is missing the key \"{e.args[0]}\"")
sys.exit(1)
except subprocess.CalledProcessError as e:
print_error_message(f"Failed to install [b]{name}[/]: build failed: \"{e.stderr.decode()}\"")
sys.exit(1)
console.log(f"[d][:white_check_mark:] Built {name}.[/]")
console.log(f"[d][:white_check_mark:] Copied {name}.[/]")
else:
# build source code
out_path = os.path.join(comet_libs_dir, f"{name}.cometlib")
try:
subprocess.run(
["gcc"] + glob.glob("src/*.c", recursive=True) + ["-fPIC", "-shared", "-Wl,-undefined,symbol_lookup", "-o", out_path] + rock_info.get("gccArgs", []),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
check=True
)
except KeyError as e:
print_error_message(f"Failed to install [b]{name}[/]: \"rock.json\" is missing the key \"{e.args[0]}\"")
sys.exit(1)
except subprocess.CalledProcessError as e:
print_error_message(f"Failed to install [b]{name}[/]: build failed: \"{e.stderr.decode()}\"")
sys.exit(1)
console.log(f"[d][:white_check_mark:] Built {name}.[/]")
data_path = os.path.join(comet_libs_dir, "lib_data")

View File

@@ -29,19 +29,20 @@ def get_needed_headers() -> bool:
console.log("[d][:white_check_mark:] Cloned Comet repo.[/]")
os.chdir(temp_dir)
status.update("Building Comet...")
result = subprocess.run(["make"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode != 0:
print_error_message(f"failed to build Comet: {result.stderr.decode()}")
console.log("[d][:white_check_mark:] Built Comet.[/]")
status.update("Installing...")
status.stop()
console.print("You may need to type your admin password: ")
result = subprocess.run(["sudo", "make", "install"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result = subprocess.run("sudo mkdir /usr/local/include/comet -p", stderr=subprocess.PIPE, shell=True)
if result.returncode != 0:
print_error_message(f"failed to install: {result.stderr.decode()}")
return False
result = subprocess.run("sudo cp include/* /usr/local/include/comet -rf", stderr=subprocess.PIPE, shell=True)
if result.returncode != 0:
print_error_message(f"failed to install: {result.stderr.decode()}")
return False
console.log("[d][:white_check_mark:] Installed headers.[/]")
console.log("[b][:white_check_mark:] Comet headers are installed![/b]\n")

View File

@@ -5,7 +5,7 @@ with open("neb/README.md", "r") as f:
setup(
name="nebpkg",
version="1.1.0",
version="1.2.0",
description="Nebula, the package manager for the Comet programming language.",
classifiers=[
"Development Status :: 4 - Beta",