Compare commits
	
		
			2 Commits
		
	
	
		
			d502f35da4
			...
			8d915f03bf
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 8d915f03bf | |
|  | 4507ec33aa | 
|  | @ -33,6 +33,7 @@ src/graphics/orca_gl31.h | ||||||
| .vscode/settings.json | .vscode/settings.json | ||||||
| 
 | 
 | ||||||
| __pycache__ | __pycache__ | ||||||
|  | /.cache | ||||||
| scripts/files | scripts/files | ||||||
| 
 | 
 | ||||||
| # explicitly abandon old ext dir | # explicitly abandon old ext dir | ||||||
|  |  | ||||||
|  | @ -7,6 +7,7 @@ import subprocess | ||||||
| from argparse import ArgumentParser | from argparse import ArgumentParser | ||||||
| 
 | 
 | ||||||
| from .log import * | from .log import * | ||||||
|  | from .version import install_dir | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def attach_bundle_commands(subparsers): | def attach_bundle_commands(subparsers): | ||||||
|  |  | ||||||
|  | @ -575,6 +575,8 @@ def install(args): | ||||||
|     dest = install_dir() |     dest = install_dir() | ||||||
|     bin_dir = os.path.join(dest, "bin") |     bin_dir = os.path.join(dest, "bin") | ||||||
|     src_dir = os.path.join(dest, "src") |     src_dir = os.path.join(dest, "src") | ||||||
|  |     runtime_dir = os.path.join(dest, "build", "bin") | ||||||
|  |     resources_dir = os.path.join(dest, "resources") | ||||||
|     version_file = os.path.join(dest, ".orcaversion") |     version_file = os.path.join(dest, ".orcaversion") | ||||||
| 
 | 
 | ||||||
|     version = orca_version() |     version = orca_version() | ||||||
|  | @ -597,6 +599,8 @@ def install(args): | ||||||
| 
 | 
 | ||||||
|     yeetdir(bin_dir) |     yeetdir(bin_dir) | ||||||
|     yeetdir(src_dir) |     yeetdir(src_dir) | ||||||
|  |     yeetdir(runtime_dir) | ||||||
|  |     yeetdir(resources_dir) | ||||||
|     yeetfile(version_file) |     yeetfile(version_file) | ||||||
| 
 | 
 | ||||||
|     # The MS Store version of Python does some really stupid stuff with AppData: |     # The MS Store version of Python does some really stupid stuff with AppData: | ||||||
|  | @ -617,6 +621,8 @@ def install(args): | ||||||
|     shutil.copytree("scripts", os.path.join(bin_dir, "sys_scripts")) |     shutil.copytree("scripts", os.path.join(bin_dir, "sys_scripts")) | ||||||
|     shutil.copy("orca", bin_dir) |     shutil.copy("orca", bin_dir) | ||||||
|     shutil.copytree("src", src_dir, dirs_exist_ok=True) |     shutil.copytree("src", src_dir, dirs_exist_ok=True) | ||||||
|  |     shutil.copytree(os.path.join("build", "bin"), runtime_dir, dirs_exist_ok=True) | ||||||
|  |     shutil.copytree("resources", resources_dir, dirs_exist_ok=True) | ||||||
|     if platform.system() == "Windows": |     if platform.system() == "Windows": | ||||||
|         shutil.copy("orca.bat", bin_dir) |         shutil.copy("orca.bat", bin_dir) | ||||||
|     with open(version_file, "w") as f: |     with open(version_file, "w") as f: | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ import shutil | ||||||
| from .checksum import dirsum | from .checksum import dirsum | ||||||
| from .log import * | from .log import * | ||||||
| from .utils import yeetdir | from .utils import yeetdir | ||||||
| from .version import src_dir, orca_version | from .version import orca_version, install_dir | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def attach_source_commands(subparsers): | def attach_source_commands(subparsers): | ||||||
|  | @ -15,7 +15,7 @@ def attach_source_commands(subparsers): | ||||||
|     source_sub = source_cmd.add_subparsers(required=True, title="commands") |     source_sub = source_cmd.add_subparsers(required=True, title="commands") | ||||||
| 
 | 
 | ||||||
|     cflags_cmd = source_sub.add_parser("cflags", help="Get help setting up a C or C++ compiler to compile the Orca source.") |     cflags_cmd = source_sub.add_parser("cflags", help="Get help setting up a C or C++ compiler to compile the Orca source.") | ||||||
|     cflags_cmd.add_argument("srcdir", nargs="?", default=src_dir(), help="the directory containing the Orca source code (defaults to system installation)") |     cflags_cmd.add_argument("srcdir", nargs="?", default=path_in_install("src"), help="the directory containing the Orca source code (defaults to system installation)") | ||||||
|     cflags_cmd.set_defaults(func=shellish(cflags)) |     cflags_cmd.set_defaults(func=shellish(cflags)) | ||||||
| 
 | 
 | ||||||
|     vendor_cmd = source_sub.add_parser("vendor", help="Copy the Orca source code into your project.") |     vendor_cmd = source_sub.add_parser("vendor", help="Copy the Orca source code into your project.") | ||||||
|  | @ -23,6 +23,10 @@ def attach_source_commands(subparsers): | ||||||
|     vendor_cmd.set_defaults(func=shellish(vendor)) |     vendor_cmd.set_defaults(func=shellish(vendor)) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | def path_in_install(path): | ||||||
|  |     return os.path.join(install_dir(), path) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def vendor(args): | def vendor(args): | ||||||
|     # Verify that we are ok to vendor into the requested dir. |     # Verify that we are ok to vendor into the requested dir. | ||||||
|     if os.path.exists(args.dir): |     if os.path.exists(args.dir): | ||||||
|  | @ -41,12 +45,19 @@ def vendor(args): | ||||||
|                 exit(1) |                 exit(1) | ||||||
| 
 | 
 | ||||||
|     yeetdir(args.dir) |     yeetdir(args.dir) | ||||||
|     shutil.copytree(src_dir(), args.dir) | 
 | ||||||
|  |     vendor_src = os.path.join(args.dir, "src") | ||||||
|  |     vendor_runtime = os.path.join(args.dir, "build", "bin") | ||||||
|  |     vendor_resources = os.path.join(args.dir, "resources") | ||||||
|  |     shutil.copytree(path_in_install("src"), vendor_src) | ||||||
|  |     shutil.copytree(path_in_install("build/bin"), vendor_runtime) | ||||||
|  |     shutil.copytree(path_in_install("resources"), vendor_resources) | ||||||
|     with open(vendor_file_path(args.dir), "w") as f: |     with open(vendor_file_path(args.dir), "w") as f: | ||||||
|         json.dump({ |         json.dump({ | ||||||
|             "version": orca_version(), |             "version": orca_version(), | ||||||
|             "checksum": vendor_checksum(args.dir), |             "checksum": vendor_checksum(args.dir), | ||||||
|         }, f, indent=2) |         }, f, indent=2) | ||||||
|  | 
 | ||||||
|     print(f"Version {orca_version()} of the Orca source code has been copied to {args.dir}.") |     print(f"Version {orca_version()} of the Orca source code has been copied to {args.dir}.") | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -38,20 +38,13 @@ def is_orca_source(): | ||||||
|     return use_source |     return use_source | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def actual_install_dir(): | def install_dir(): | ||||||
|     # The path adjustment in here is technically sort of fragile because it depends |     # The path adjustment in here is technically sort of fragile because it depends | ||||||
|     # on the current location of this actual file. But oh well. |     # on the current location of this actual file. But oh well. | ||||||
|     if is_orca_source(): |     if is_orca_source(): | ||||||
|         raise Exception("actual_install_dir should not be called when using the source version of the Orca tools") |         return os.path.normpath(os.path.join(os.path.abspath(__file__), "../..")) | ||||||
|     return os.path.normpath(os.path.join(os.path.abspath(__file__), "../../..")) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| def src_dir(): |  | ||||||
|     # More fragile path adjustments! Yay! |  | ||||||
|     if is_orca_source(): |  | ||||||
|         return os.path.normpath(os.path.join(os.path.abspath(__file__), "../../src")) |  | ||||||
|     else: |     else: | ||||||
|         return os.path.normpath(os.path.join(os.path.abspath(__file__), "../../../src")) |         return os.path.normpath(os.path.join(os.path.abspath(__file__), "../../..")) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def orca_version(): | def orca_version(): | ||||||
|  | @ -68,7 +61,7 @@ def orca_version(): | ||||||
|             return f"dev-{version}" |             return f"dev-{version}" | ||||||
|     else: |     else: | ||||||
|         try: |         try: | ||||||
|             with open(os.path.join(actual_install_dir(), ".orcaversion"), "r") as f: |             with open(os.path.join(install_dir(), ".orcaversion"), "r") as f: | ||||||
|                 version = f.read().strip() |                 version = f.read().strip() | ||||||
|                 return version |                 return version | ||||||
|         except FileNotFoundError: |         except FileNotFoundError: | ||||||
|  | @ -92,4 +85,4 @@ def print_orca_version(args): | ||||||
|         sys.stderr.write(f"Source dir: {source_dir}\n") |         sys.stderr.write(f"Source dir: {source_dir}\n") | ||||||
|     else: |     else: | ||||||
|         sys.stderr.write(f"Orca is running from a system installation.\n") |         sys.stderr.write(f"Orca is running from a system installation.\n") | ||||||
|         sys.stderr.write(f"Install dir: {actual_install_dir()}\n") |         sys.stderr.write(f"Install dir: {install_dir()}\n") | ||||||
|  |  | ||||||
|  | @ -91,21 +91,22 @@ oc_str8 oc_run_cmd(oc_arena* arena, oc_str8 cmd) | ||||||
|     char* outputBuf = NULL; |     char* outputBuf = NULL; | ||||||
|     while(true) |     while(true) | ||||||
|     { |     { | ||||||
|         const int chunkSize = 1024; | // TODO: apply smartness to this number
 | ||||||
|         char* chunk = oc_arena_push(arena, chunkSize); | #define CHUNK_SIZE 1024 | ||||||
|         if(outputBuf == NULL) |         char chunkBuf[CHUNK_SIZE]; | ||||||
|         { |  | ||||||
|             // Initialize output buffer to first allocated chunk
 |  | ||||||
|             outputBuf = chunk; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         DWORD nRead; |         DWORD nRead; | ||||||
|         BOOL success = ReadFile(childStdoutRd, chunk, chunkSize, &nRead, NULL); |         BOOL success = ReadFile(childStdoutRd, chunkBuf, CHUNK_SIZE, &nRead, NULL); | ||||||
|         if(!success || nRead == 0) |         if(!success || nRead == 0) | ||||||
|         { |         { | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         char* dst = oc_arena_push(arena, nRead); | ||||||
|  |         if(!outputBuf) | ||||||
|  |         { | ||||||
|  |             outputBuf = dst; | ||||||
|  |         } | ||||||
|  |         memcpy(dst, chunkBuf, nRead); | ||||||
|         outputLen += nRead; |         outputLen += nRead; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue