diff --git a/neb/README.md b/neb/README.md index 1fcc016..ed6a621 100644 --- a/neb/README.md +++ b/neb/README.md @@ -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 diff --git a/neb/src/install.py b/neb/src/install.py index 1fa78f7..fb42bcd 100644 --- a/neb/src/install.py +++ b/neb/src/install.py @@ -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") diff --git a/neb/src/util.py b/neb/src/util.py index 4706dbf..abfee35 100644 --- a/neb/src/util.py +++ b/neb/src/util.py @@ -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") diff --git a/setup.py b/setup.py index d392924..6f8e9a6 100644 --- a/setup.py +++ b/setup.py @@ -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",