Skip to content

Commit 4d6e715

Browse files
committed
Update build_native.py
1 parent 81c1b51 commit 4d6e715

File tree

1 file changed

+46
-46
lines changed

1 file changed

+46
-46
lines changed

build_native.py

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -111,39 +111,39 @@ def _get_link_flags(self) -> list:
111111

112112
def check_dependencies(self) -> bool:
113113
"""Check if all required dependencies are available."""
114-
print("🔍 Checking build dependencies...")
114+
print("Checking build dependencies...")
115115

116116
# Check compilers
117117
if 'c' not in self.compilers:
118-
print("C compiler not found. Please install gcc, clang, or equivalent.")
118+
print("C compiler not found. Please install gcc, clang, or equivalent.")
119119
return False
120120

121121
if 'cxx' not in self.compilers:
122-
print("C++ compiler not found. Please install g++, clang++, or equivalent.")
122+
print("C++ compiler not found. Please install g++, clang++, or equivalent.")
123123
return False
124124

125-
print(f"C compiler: {self.compilers['c']}")
126-
print(f"C++ compiler: {self.compilers['cxx']}")
127-
print(f"Platform: {self.platform}")
128-
print(f"Library extension: {self.lib_extension}")
125+
print(f"C compiler: {self.compilers['c']}")
126+
print(f"C++ compiler: {self.compilers['cxx']}")
127+
print(f"Platform: {self.platform}")
128+
print(f"Library extension: {self.lib_extension}")
129129

130130
return True
131131

132132
def create_directories(self):
133133
"""Create necessary directories."""
134-
print("📁 Creating directories...")
134+
print("Creating directories...")
135135
self.platform_dir.mkdir(parents=True, exist_ok=True)
136-
print(f"Created: {self.platform_dir}")
136+
print(f"Created: {self.platform_dir}")
137137

138138
def compile_crypto_core(self) -> bool:
139139
"""Compile crypto_core library."""
140-
print("🔨 Compiling crypto_core library...")
140+
print("Compiling crypto_core library...")
141141

142142
source_file = self.native_dir / 'crypto_core.c'
143143
output_file = self.platform_dir / f'libcrypto_core{self.lib_extension}'
144144

145145
if not source_file.exists():
146-
print(f"Source file not found: {source_file}")
146+
print(f"Source file not found: {source_file}")
147147
return False
148148

149149
# Build command
@@ -160,27 +160,27 @@ def compile_crypto_core(self) -> bool:
160160
result = subprocess.run(cmd, capture_output=True, text=True, cwd=self.native_dir)
161161

162162
if result.returncode == 0:
163-
print(f"crypto_core library built: {output_file}")
163+
print(f"crypto_core library built: {output_file}")
164164
return True
165165
else:
166-
print(f"Compilation failed:")
166+
print(f"Compilation failed:")
167167
print(f" stdout: {result.stdout}")
168168
print(f" stderr: {result.stderr}")
169169
return False
170170

171171
except Exception as e:
172-
print(f"Compilation error: {e}")
172+
print(f"Compilation error: {e}")
173173
return False
174174

175175
def compile_hash_algorithms(self) -> bool:
176176
"""Compile hash_algorithms library."""
177-
print("🔨 Compiling hash_algorithms library...")
177+
print("Compiling hash_algorithms library...")
178178

179179
source_file = self.native_dir / 'hash_algorithms.cpp'
180180
output_file = self.platform_dir / f'libhash_algorithms{self.lib_extension}'
181181

182182
if not source_file.exists():
183-
print(f"Source file not found: {source_file}")
183+
print(f"Source file not found: {source_file}")
184184
return False
185185

186186
# Build command
@@ -197,21 +197,21 @@ def compile_hash_algorithms(self) -> bool:
197197
result = subprocess.run(cmd, capture_output=True, text=True, cwd=self.native_dir)
198198

199199
if result.returncode == 0:
200-
print(f"hash_algorithms library built: {output_file}")
200+
print(f"hash_algorithms library built: {output_file}")
201201
return True
202202
else:
203-
print(f"Compilation failed:")
203+
print(f"Compilation failed:")
204204
print(f" stdout: {result.stdout}")
205205
print(f" stderr: {result.stderr}")
206206
return False
207207

208208
except Exception as e:
209-
print(f"Compilation error: {e}")
209+
print(f"Compilation error: {e}")
210210
return False
211211

212212
def test_libraries(self) -> bool:
213213
"""Test compiled libraries."""
214-
print("🧪 Testing compiled libraries...")
214+
print("Testing compiled libraries...")
215215

216216
try:
217217
# Try to load the libraries using Python
@@ -225,13 +225,13 @@ def test_libraries(self) -> bool:
225225
success = True
226226
for lib_name, loaded in results.items():
227227
if loaded:
228-
print(f"{lib_name}: loaded successfully")
228+
print(f"{lib_name}: loaded successfully")
229229
else:
230-
print(f"{lib_name}: failed to load")
230+
print(f"{lib_name}: failed to load")
231231
success = False
232232

233233
if success:
234-
print("🎉 All libraries loaded successfully!")
234+
print("All libraries loaded successfully!")
235235

236236
# Run basic functionality tests
237237
if manager.crypto_core:
@@ -240,40 +240,40 @@ def test_libraries(self) -> bool:
240240
test_data = b"Hello, World!"
241241
test_key = b"key123"
242242
result = manager.crypto_core.fast_xor(test_data, test_key)
243-
print("✅ crypto_core: XOR operation test passed")
243+
print("XOR operation test passed")
244244

245245
# Test entropy calculation
246246
entropy = manager.crypto_core.calculate_entropy(test_data)
247-
print(f"✅ crypto_core: Entropy calculation test passed (entropy: {entropy:.2f})")
247+
print(f"Entropy calculation test passed (entropy: {entropy:.2f})")
248248

249249
except Exception as e:
250-
print(f"❌ crypto_core: Functionality test failed: {e}")
250+
print(f"Functionality test failed: {e}")
251251
success = False
252252

253253
if manager.hash_algorithms:
254254
try:
255255
# Test SHA-256
256256
test_data = b"Hello, World!"
257257
hash_result = manager.hash_algorithms.fast_sha256(test_data)
258-
print(f"hash_algorithms: SHA-256 test passed (hash: {hash_result[:8].hex()}...)")
258+
print(f"hash_algorithms: SHA-256 test passed (hash: {hash_result[:8].hex()}...)")
259259

260260
# Test key generation
261261
private_key, public_key = manager.hash_algorithms.generate_keypair()
262-
print(f"hash_algorithms: Key generation test passed")
262+
print(f"hash_algorithms: Key generation test passed")
263263

264264
except Exception as e:
265-
print(f"hash_algorithms: Functionality test failed: {e}")
265+
print(f"hash_algorithms: Functionality test failed: {e}")
266266
success = False
267267

268268
return success
269269

270270
except Exception as e:
271-
print(f"Library testing failed: {e}")
271+
print(f"Library testing failed: {e}")
272272
return False
273273

274274
def build_all(self) -> bool:
275275
"""Build all native libraries."""
276-
print("🚀 Building Encrypter Native Libraries")
276+
print("Building Encrypter Native Libraries")
277277
print("=" * 50)
278278

279279
# Check dependencies
@@ -293,63 +293,63 @@ def build_all(self) -> bool:
293293
success = False
294294

295295
if success:
296-
print("\n🎉 All libraries compiled successfully!")
296+
print("\nAll libraries compiled successfully!")
297297

298298
# Test libraries
299299
if self.test_libraries():
300-
print("\n✅ Build completed successfully!")
301-
print(f"📦 Libraries available in: {self.platform_dir}")
300+
print("\nBuild completed successfully!")
301+
print(f"Libraries available in: {self.platform_dir}")
302302
return True
303303
else:
304-
print("\n❌ Library testing failed!")
304+
print("\nLibrary testing failed!")
305305
return False
306306
else:
307-
print("\n❌ Build failed!")
307+
print("\nBuild failed!")
308308
return False
309309

310310
def clean(self):
311311
"""Clean build artifacts."""
312-
print("🧹 Cleaning build artifacts...")
312+
print("Cleaning build artifacts...")
313313

314314
if self.libs_dir.exists():
315315
shutil.rmtree(self.libs_dir)
316-
print(f"Removed: {self.libs_dir}")
316+
print(f"Removed: {self.libs_dir}")
317317
else:
318-
print("No build artifacts to clean")
318+
print("No build artifacts to clean")
319319

320320
def install_system_wide(self) -> bool:
321321
"""Install libraries system-wide (optional)."""
322-
print("📦 Installing libraries system-wide...")
322+
print("Installing libraries system-wide...")
323323

324324
if self.platform == 'linux':
325325
try:
326326
for lib_file in self.platform_dir.glob('*.so'):
327327
dest = Path('/usr/local/lib') / lib_file.name
328328
subprocess.run(['sudo', 'cp', str(lib_file), str(dest)], check=True)
329-
print(f"Installed: {dest}")
329+
print(f"Installed: {dest}")
330330

331331
subprocess.run(['sudo', 'ldconfig'], check=True)
332-
print("Updated library cache")
332+
print("Updated library cache")
333333
return True
334334

335335
except subprocess.CalledProcessError as e:
336-
print(f"Installation failed: {e}")
336+
print(f"Installation failed: {e}")
337337
return False
338338

339339
elif self.platform == 'macos':
340340
try:
341341
for lib_file in self.platform_dir.glob('*.dylib'):
342342
dest = Path('/usr/local/lib') / lib_file.name
343343
subprocess.run(['sudo', 'cp', str(lib_file), str(dest)], check=True)
344-
print(f"Installed: {dest}")
344+
print(f"Installed: {dest}")
345345
return True
346346

347347
except subprocess.CalledProcessError as e:
348-
print(f"Installation failed: {e}")
348+
print(f"Installation failed: {e}")
349349
return False
350350

351351
else:
352-
print("ℹ️ System-wide installation not supported on Windows")
352+
print("System-wide installation not supported on Windows")
353353
return True
354354

355355

0 commit comments

Comments
 (0)