summaryrefslogtreecommitdiffhomepage
path: root/tooling
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-05-29 10:51:53 +0200
committerGitHub <noreply@github.com>2025-05-29 10:51:53 +0200
commit5c0bb7ee7b1b0fee02cc179fb21f4c57a61d6c2d (patch)
treecb17577bcdc9714c97a84ce417a075117097f146 /tooling
parentd608230b1350b064ceb01e6572519b108f6139b0 (diff)
parent3167f59dbb401d6a79b1524537e04218baf49ee3 (diff)
Merge pull request #32 from nekernel-org/dev
0.0.2e3
Diffstat (limited to 'tooling')
-rw-r--r--tooling/fsck.hefs.cc2
-rw-r--r--tooling/manual.py9
-rwxr-xr-xtooling/mk_app.py80
-rwxr-xr-xtooling/mk_fwrk.py46
-rwxr-xr-xtooling/mk_img.py12
-rw-r--r--tooling/mkfs.hefs.cc4
6 files changed, 122 insertions, 31 deletions
diff --git a/tooling/fsck.hefs.cc b/tooling/fsck.hefs.cc
index 96cd36b6..ce586b13 100644
--- a/tooling/fsck.hefs.cc
+++ b/tooling/fsck.hefs.cc
@@ -15,7 +15,5 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
- (void) argv;
-
return EXIT_SUCCESS;
} \ No newline at end of file
diff --git a/tooling/manual.py b/tooling/manual.py
new file mode 100644
index 00000000..8298559b
--- /dev/null
+++ b/tooling/manual.py
@@ -0,0 +1,9 @@
+#! /usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import sys, os
+
+if __name__ == "__main__":
+ if len(sys.argv) != 2:
+ print("Usage: manual.py <manual_path>")
+ sys.exit(os.EX_CONFIG)
diff --git a/tooling/mk_app.py b/tooling/mk_app.py
new file mode 100755
index 00000000..5ee6d5b7
--- /dev/null
+++ b/tooling/mk_app.py
@@ -0,0 +1,80 @@
+#! /usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import os
+import json
+import sys
+
+def create_directory_structure(base_path, project_name):
+ # Define the directory structure
+ structure = {
+ project_name: {
+ "dist": {
+ ".keep": None
+ },
+ "src": {
+ ".keep": None,
+ "CommandLine.cc": None,
+ },
+ "vendor": {
+ ".keep": None
+ },
+ ".keep": None,
+ f"{project_name}.json": {}
+ }
+ }
+
+ def create_structure(path, structure):
+ for name, content in structure.items():
+ current_path = os.path.join(path, name)
+ # Create directories or files based on the content type
+ if isinstance(content, dict) and current_path.endswith(".json") == False:
+ os.makedirs(current_path, exist_ok=True)
+ create_structure(current_path, content)
+ elif content is None:
+ # Create an empty file
+ with open(current_path, 'w') as f:
+ pass
+
+ # Create the base directory
+ os.makedirs(base_path, exist_ok=True)
+ create_structure(base_path, structure)
+
+ # Create the JSON file
+ proj_json_path = os.path.join(base_path, project_name, f"{project_name}.json")
+
+ manifest = {
+ "compiler_path": "clang++",
+ "compiler_std": "c++20",
+ "headers_path": ["./", "../../../dev/kernel", "../../../public/frameworks/", "../../../dev/", "./"],
+ "sources_path": [
+
+ ],
+ "output_name": f"./dist/{project_name}",
+ "cpp_macros": [
+ "kSampleFWVersion=0x0100",
+ "kSampleFWVersionHighest=0x0100",
+ "kSampleFWVersionLowest=0x0100",
+ "__NE_SDK__"
+ ]
+ }
+
+ with open(proj_json_path, 'w') as json_file:
+ json.dump(manifest, json_file, indent=4)
+
+ proj_cpp_path = os.path.join(base_path, project_name, f"src/CommandLine.cc")
+
+ cpp_file = "#include <libSystem/System.h>\n\nSInt32 _NeMain(SInt32 argc, Char* argv[]) {\n\treturn EXIT_FAILURE;\n}"
+
+ with open(proj_cpp_path, 'w') as cpp_file_io:
+ cpp_file_io.write(cpp_file)
+
+if __name__ == "__main__":
+ if len(sys.argv) != 2:
+ print("HELP: mk_app.py <project_name>")
+ sys.exit(os.EX_CONFIG)
+
+ base_path = os.getcwd() # Use the current working directory as the base path
+ create_directory_structure(base_path, sys.argv[1])
+
+ print("INFO: Application created successfully.")
diff --git a/tooling/mk_fwrk.py b/tooling/mk_fwrk.py
index 9bc132e6..e4e5d7de 100755
--- a/tooling/mk_fwrk.py
+++ b/tooling/mk_fwrk.py
@@ -5,27 +5,33 @@ import os
import json
import sys
-def create_directory_structure(base_path, project_name):
+"""
+ Create directory structure for the framework.
+"""
+def create_directory_structure(base_path_fwrk, project_file_name, project_name):
# Define the directory structure
structure = {
project_name: {
+ "headers": {
+ ".keep": None
+ },
"dist": {
".keep": None
},
"src": {
".keep": None,
- "CommandLine.cc": None,
+ "DylibMain.cc": None,
},
- "vendor": {
+ "xml": {
".keep": None
},
".keep": None,
- f"{project_name}.json": {}
+ f"{project_file_name}.json": {}
}
}
- def create_structure(path, structure):
- for name, content in structure.items():
+ def create_structure(path, structure_in):
+ for name, content in structure_in.items():
current_path = os.path.join(path, name)
# Create directories or files based on the content type
if isinstance(content, dict) and current_path.endswith(".json") == False:
@@ -37,18 +43,18 @@ def create_directory_structure(base_path, project_name):
pass
# Create the base directory
- os.makedirs(base_path, exist_ok=True)
- create_structure(base_path, structure)
+ os.makedirs(base_path_fwrk, exist_ok=True)
+ create_structure(base_path_fwrk, structure)
# Create the JSON file
- proj_json_path = os.path.join(base_path, project_name, f"{project_name}.json")
+ proj_json_path = os.path.join(base_path_fwrk, project_name, f"{project_file_name}.json")
manifest = {
"compiler_path": "clang++",
"compiler_std": "c++20",
"headers_path": ["./", "../../../dev/kernel", "../../../public/frameworks/", "../../../dev/", "./"],
"sources_path": [
-
+
],
"output_name": f"./dist/{project_name}",
"cpp_macros": [
@@ -58,23 +64,29 @@ def create_directory_structure(base_path, project_name):
"__NE_SDK__"
]
}
-
+
with open(proj_json_path, 'w') as json_file:
json.dump(manifest, json_file, indent=4)
- proj_cpp_path = os.path.join(base_path, project_name, f"src/CommandLine.cc")
+ proj_cpp_path = os.path.join(base_path_fwrk, project_name, f"src/DylibMain.cc")
- cpp_file = "#include <user/SystemCalls.h>\n\nSInt32 _NeMain(SInt32 argc, Char* argv[]) {\n\treturn EXIT_FAILURE;\n}"
+ cpp_file = "#include <libSystem/System.h>\n\nSInt32 _DylibAttach(SInt32 argc, Char* argv[]) {\n\treturn EXIT_FAILURE;\n}"
with open(proj_cpp_path, 'w') as cpp_file_io:
cpp_file_io.write(cpp_file)
+ xml_blob = f"<PropertyList>\n<PLEntry Type=\"CFString\" Name=\"LibraryName\" Len=\"{len(project_name)}\" Value=\"{project_name}\" /></PropertyList>"
+ proj_xml_path = os.path.join(base_path_fwrk, project_name, f"xml/app.xml")
+
+ with open(proj_xml_path, 'w') as cpp_file_io:
+ cpp_file_io.write(xml_blob)
+
if __name__ == "__main__":
if len(sys.argv) != 2:
- print("Usage: mk_fwrk.py <project_name>")
+ print("HELP: mk_fwrk.py <project_name>")
sys.exit(os.EX_CONFIG)
base_path = os.getcwd() # Use the current working directory as the base path
- create_directory_structure(base_path, sys.argv[1])
-
- print("NeKernel framework created successfully.")
+ create_directory_structure(base_path, sys.argv[1], sys.argv[1] + '.fwrk')
+
+ print("INFO: Framework created successfully.")
diff --git a/tooling/mk_img.py b/tooling/mk_img.py
index 8227a217..28af22e3 100755
--- a/tooling/mk_img.py
+++ b/tooling/mk_img.py
@@ -24,21 +24,13 @@ def copy_to_fat(image_path, source_dir):
command = ["mcopy", "-spm", "-i", image_path] + files_to_copy + ["::"]
subprocess.run(command, check=True)
-
- print(f"Info: Successfully copied contents of '{source_dir}' into '{image_path}'")
- except FileNotFoundError:
- print("Error: mcopy is not installed. Please install mtools.")
- sys.exit(1)
- except subprocess.CalledProcessError as e:
- print(f"Error: mcopy failed with error code {e.returncode}.")
- sys.exit(1)
except Exception as e:
print(f"Error: failed: {e}")
sys.exit(1)
if __name__ == "__main__":
if len(sys.argv) != 3:
- print("Usage: mk_img.py <fat32_image> <source_directory>")
+ print("HELP: mk_img.py <fat32_image> <source_directory>")
sys.exit(1)
image_path = sys.argv[1]
@@ -46,4 +38,4 @@ if __name__ == "__main__":
copy_to_fat(image_path, source_dir)
- print("NeKernel image created successfully.")
+ print("INFO: Image created successfully.")
diff --git a/tooling/mkfs.hefs.cc b/tooling/mkfs.hefs.cc
index 3dcfd11b..fcb0c006 100644
--- a/tooling/mkfs.hefs.cc
+++ b/tooling/mkfs.hefs.cc
@@ -55,7 +55,7 @@ int main(int argc, char** argv) {
kLabel = mkfs::get_option<char8_t>(args_wide, u8"-L");
if (!kSectorSize) {
- mkfs::console_out() << "hefs: error: Sector size size is zero.\n";
+ mkfs::console_out() << "hefs: error: Sector size size is set to zero.\n";
return EXIT_FAILURE;
}
@@ -65,7 +65,7 @@ int main(int argc, char** argv) {
std::strtol(mkfs::get_option<char>(args, "-S").data(), nullptr, 10) * 1024 * 1024 * 1024;
if (!kDiskSize) {
- mkfs::console_out() << "hefs: error: Disk size is zero.\n";
+ mkfs::console_out() << "hefs: error: Disk size is set to zero.\n";
return EXIT_FAILURE;
}