Compare commits

...

13 Commits

Author SHA1 Message Date
Ronaldson Bellande
d01497ee93 Update README.md 2024-10-27 10:15:46 -04:00
Ronaldson Bellande
e1ff513d03 Create CODE_OF_CONDUCT.md 2024-10-26 20:57:45 -04:00
f15cc23ab0 latest pushes 2024-10-14 00:20:24 -04:00
239194abf5 latest pushes 2024-10-13 21:46:43 -04:00
56a3891b99 latest pushes 2024-10-13 19:03:12 -04:00
4fff24ea42 Merge branch 'main' of github.com:Algorithm-Model-Research/bellande_rust_executable into main
readme
2024-10-12 17:44:29 -04:00
Ronaldson Bellande
b2268129be Update README.md 2024-10-07 20:05:51 -04:00
Ronaldson Bellande
077e9d050f Update README.md 2024-10-07 20:04:20 -04:00
Ronaldson Bellande
05bc0da89e Update README.md 2024-10-07 19:48:25 -04:00
792c4e102a Merge remote-tracking branch 'origin/main' into main 2024-10-03 23:17:10 -04:00
5db772df02 Merge remote-tracking branch 'origin/main' into main 2024-10-02 12:47:19 -04:00
ea2f35ce8c latest pushes 2024-10-02 12:46:57 -04:00
1ddccb7c1b latest pushes 2024-09-29 16:38:10 -04:00
3 changed files with 100 additions and 40 deletions

71
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,71 @@
# Code of Conduct - Architectural Standards
## Our Pledge
In the interest of fostering a clear and consistent development environment, we pledge to maintain architectural integrity across all programming languages and implementations within this project.
## Fundamental Principle
- **Architectural names remain consistent and unchanging regardless of programming language implementation. Whether written in Python, Java, C++, or any other language, the architectural pattern's name and core principles remain identical and immutable.**
## Our Standards
### Architectural Consistency
We recognize that architectural patterns and their nomenclature remain constant regardless of the programming language used for implementation. This means:
1. Architectural pattern names shall remain consistent across all programming languages
2. The fundamental principles of each architectural pattern shall be preserved regardless of implementation
3. Documentation must reference architectural patterns using their standard industry names
### Examples of Name Preservation
- A **Repository Pattern** remains a "Repository Pattern" whether implemented in:
- Java
- Python
- C#
- JavaScript
- Go
- Any other programming language
- An **Event Sourcing** architecture remains "Event Sourcing" whether built in:
- Rust
- Kotlin
- TypeScript
- PHP
- Any other technology stack
- **Regardless of the programming language used, the name Bellande remains consistent across all architectures and code**
### Implementation Guidelines
1. When implementing architectural patterns:
- Always use the standard architectural name
- Never rename patterns based on language preferences
- Document implementations using consistent architectural terminology
- Maintain pattern names even when adapting to language-specific features
2. Code organization must:
- Use standard architectural pattern names in all documentation
- Maintain consistent naming across different services/modules
- Reflect the chosen architecture's established terminology
- Preserve architectural names in comments and documentation
## Enforcement
Project maintainers are responsible for:
1. Enforcing consistent architectural naming across all implementations
2. Reviewing code to ensure architectural pattern names remain standard
3. Providing guidance on proper architectural pattern naming
4. Maintaining documentation that reflects these naming standards
## Questions and Clarifications
If you have questions about:
- How to properly name architectural patterns in your implementation
- Whether your naming conventions align with architectural standards
- How to maintain naming consistency across different services
Please reach out to the project maintainers or consult the architecture documentation.
## Version and Updates
- Version: 1.0
- Last Updated: October 26, 2024
This Code of Conduct is a living document and may be updated to better serve the project's needs while maintaining its core principle of architectural naming consistency.
## Organization Code of Conduct
The latest uptodate Code of Conduct will be distributed under the [CODE_OF_CONDUCT](https://github.com/Architecture-Mechanism/CODE_OF_CONDUCT)

View File

@@ -1,7 +1,10 @@
# Bellande Rust Executable # Bellande Rust Executable
## Bellande Rust Executable is a library that makes rust code into an executable (BRE) library ## Bellande Rust Executable is a library that makes rust code into an executable (BRE) library
- "-d", "--dep-file", required=True, help="Path to the dependencies file (dependencies.bellande)"
- "-s", "--src-dir", required=True, help="Source directory containing Rust files"
- "-m", "--main-file", required=True, help="Main Rust file name (e.g., main.rs)"
- "-o", "--output", required=True, help="Output path for the compiled executable"
## Website PYPI ## Website PYPI
- https://pypi.org/project/bellande_rust_executable - https://pypi.org/project/bellande_rust_executable
@@ -14,16 +17,16 @@
``` ```
Name: bellande_rust_executable Name: bellande_rust_executable
Version: 0.1.0
Summary: File type Formats Summary: File type Formats
Home-page: github.com/RonaldsonBellande/bellande_rust_executable Home-page: github.com/RonaldsonBellande/bellande_rust_executable
Author: Ronaldson Bellande Author: Ronaldson Bellande
Author-email: ronaldsonbellande@gmail.com Author-email: ronaldsonbellande@gmail.com
License: GNU General Public License v3.0 License: GNU General Public License v3.0
Requires: numpy
Required-by:
``` ```
## License ## License
Bellande Rust Executable Packages is distributed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), see [LICENSE](https://github.com/Algorithm-Model-Research/bellande_rust_executable/blob/main/LICENSE) and [NOTICE](https://github.com/Algorithm-Model-Research/bellande_rust_executable/blob/main/LICENSE) for more information. Bellande Rust Executable Packages is distributed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), see [LICENSE](https://github.com/Architecture-Mechanism/bellande_rust_executable/blob/main/LICENSE) and [NOTICE](https://github.com/Architecture-Mechanism/bellande_rust_executable/blob/main/LICENSE) for more information.
## Code of Conduct
Bellande Rust Executable Packages is distributed under the [CODE_OF_CONDUCT](https://github.com/Architecture-Mechanism/bellande_rust_executable/blob/main/CODE_OF_CONDUCT.md) and [NOTICE](https://github.com/Architecture-Mechanism/bellande_rust_executable/blob/main/CODE_OF_CONDUCT.md) for more information.

View File

@@ -20,6 +20,7 @@ import os
import shutil import shutil
import argparse import argparse
import toml import toml
from bellande_parser.bellande_parser import Bellande_Format
def ensure_directory(path): def ensure_directory(path):
"""Ensure a directory exists and create one if it does not""" """Ensure a directory exists and create one if it does not"""
@@ -33,7 +34,7 @@ def copy_source_files(src_dir, dest_dir):
dest_src_dir = os.path.join(dest_dir, 'src') dest_src_dir = os.path.join(dest_dir, 'src')
ensure_directory(dest_src_dir) ensure_directory(dest_src_dir)
for root, dirs, files in os.walk(src_dir): for root, _, files in os.walk(src_dir):
for file in files: for file in files:
src_path = os.path.join(root, file) src_path = os.path.join(root, file)
rel_path = os.path.relpath(src_path, src_dir) rel_path = os.path.relpath(src_path, src_dir)
@@ -52,7 +53,6 @@ def create_cargo_toml(project_dir, main_file, binary_name):
'dependencies': {} 'dependencies': {}
} }
# If the main file isn't main.rs, we need to specify the path
if main_file != 'main.rs': if main_file != 'main.rs':
cargo_config['bin'] = [{ cargo_config['bin'] = [{
'name': binary_name, 'name': binary_name,
@@ -64,19 +64,22 @@ def create_cargo_toml(project_dir, main_file, binary_name):
toml.dump(cargo_config, f) toml.dump(cargo_config, f)
def parse_dependencies(dep_file): def parse_dependencies(dep_file):
"""Parse dependencies from the specified dependencies file.""" """Parse dependencies from the specified .bellande file using Bellande_Format."""
dependencies = {} bellande_parser = Bellande_Format()
if os.path.exists(dep_file): parsed_data = bellande_parser.parse_bellande(dep_file)
with open(dep_file, 'r') as file:
for line in file: # Convert the string representation to a Python dictionary
line = line.strip() dependencies = eval(parsed_data)
if line and not line.startswith('#'):
try: # Process the dependencies to match Cargo.toml format
name, version = line.split('=') processed_dependencies = {}
dependencies[name.strip()] = version.strip().strip('"') for name, value in dependencies.items():
except ValueError: if isinstance(value, str):
print(f"Warning: Skipping invalid dependency line: {line}") processed_dependencies[name] = value
return dependencies elif isinstance(value, dict):
processed_dependencies[name] = value
return processed_dependencies
def update_cargo_toml_dependencies(project_dir, dependencies): def update_cargo_toml_dependencies(project_dir, dependencies):
"""Update the dependencies in Cargo.toml.""" """Update the dependencies in Cargo.toml."""
@@ -95,18 +98,11 @@ def build_project(project_dir, output_path, binary_name):
result = subprocess.run(cargo_command, cwd=project_dir, capture_output=True, text=True) result = subprocess.run(cargo_command, cwd=project_dir, capture_output=True, text=True)
if result.returncode == 0: if result.returncode == 0:
# Determine the correct executable name based on platform exe_extension = '.exe' if os.name == 'nt' else ''
if os.name == 'nt': # Windows
exe_extension = '.exe'
else: # Unix-like systems
exe_extension = ''
# Copy the built executable to the specified output location
built_exe = os.path.join(project_dir, 'target', 'release', f"{binary_name}{exe_extension}") built_exe = os.path.join(project_dir, 'target', 'release', f"{binary_name}{exe_extension}")
ensure_directory(os.path.dirname(output_path)) ensure_directory(os.path.dirname(output_path))
shutil.copy2(built_exe, output_path) shutil.copy2(built_exe, output_path)
# Make the output file executable on Unix-like systems
if os.name != 'nt': if os.name != 'nt':
os.chmod(output_path, 0o755) os.chmod(output_path, 0o755)
@@ -119,17 +115,14 @@ def build_project(project_dir, output_path, binary_name):
def main(): def main():
parser = argparse.ArgumentParser(description="Universal Rust Executable Builder") parser = argparse.ArgumentParser(description="Universal Rust Executable Builder")
parser.add_argument("-d", "--dep-file", required=True, help="Path to the dependencies file") parser.add_argument("-d", "--dep-file", required=True, help="Path to the .bellande dependencies file")
parser.add_argument("-s", "--src-dir", required=True, help="Source directory containing Rust files") parser.add_argument("-s", "--src-dir", required=True, help="Source directory containing Rust files")
parser.add_argument("-m", "--main-file", required=True, help="Main Rust file name (e.g., main.rs)") parser.add_argument("-m", "--main-file", required=True, help="Main Rust file name (e.g., main.rs)")
parser.add_argument("-o", "--output", required=True, help="Output path for the compiled executable") parser.add_argument("-o", "--output", required=True, help="Output path for the compiled executable")
args = parser.parse_args() args = parser.parse_args()
# Extract binary name from the file name (removing .rs extension)
binary_name = os.path.splitext(args.main_file)[0] binary_name = os.path.splitext(args.main_file)[0]
# Create unique build directory based on binary name
build_dir = f"build_{binary_name}" build_dir = f"build_{binary_name}"
ensure_directory(build_dir) ensure_directory(build_dir)
@@ -137,17 +130,11 @@ def main():
copy_source_files(args.src_dir, build_dir) copy_source_files(args.src_dir, build_dir)
create_cargo_toml(build_dir, args.main_file, binary_name) create_cargo_toml(build_dir, args.main_file, binary_name)
# Parse and update dependencies
dependencies = parse_dependencies(args.dep_file) dependencies = parse_dependencies(args.dep_file)
update_cargo_toml_dependencies(build_dir, dependencies) update_cargo_toml_dependencies(build_dir, dependencies)
# Determine the correct output path based on platform output_path = f"{args.output}.exe" if os.name == 'nt' else args.output
if os.name == 'nt': # Windows
output_path = f"{args.output}.exe"
else: # Unix-like systems
output_path = args.output
# Build the project
if build_project(build_dir, output_path, binary_name): if build_project(build_dir, output_path, binary_name):
print(f"Successfully built and copied to {output_path}") print(f"Successfully built and copied to {output_path}")
return 0 return 0
@@ -156,7 +143,6 @@ def main():
return 1 return 1
finally: finally:
# Clean up build directory
shutil.rmtree(build_dir, ignore_errors=True) shutil.rmtree(build_dir, ignore_errors=True)
if __name__ == "__main__": if __name__ == "__main__":