You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

3.8 KiB

MacOS Refactoring Summary

🎯 Goal

Refactor the codebase to work seamlessly on MacOS on both x86 (Intel) and Apple Silicon (ARM64) architectures.

Key Improvements

1. Automatic Architecture Detection

  • Automatically detects Intel vs Apple Silicon
  • Sets appropriate compilation targets
  • No manual configuration required

2. Dual Architecture Support

  • x86_64: Intel-based Macs
  • arm64: Apple Silicon (M1, M2, etc.)
  • Universal: Single binary for both architectures

3. Enhanced Build System

  • New make mac target for current architecture
  • New make mac-universal target for universal binaries
  • Environment variable support (MACOS_TARGET)

4. Improved CI/CD

  • GitHub Actions now build for both architectures
  • Separate build matrices for x86_64 and ARM64
  • Architecture-specific artifact generation

🚀 New Features

Build Targets

# Build for current architecture
make mac

# Build universal binary (x86_64 + ARM64)
make mac-universal

# Build for specific architecture
MACOS_TARGET="arm64-apple-macos10.8" make mac
MACOS_TARGET="x86_64-apple-macos10.8" make mac

Utility Scripts

  • scripts/macos_arch_detect.sh - Architecture management
  • scripts/test_macos_arch.sh - System verification

📁 Files Modified

Core Build System

  • Makefile - Main build system
  • tpws/Makefile - WebSocket proxy
  • ip2net/Makefile - IP network tools
  • mdig/Makefile - DNS tools
  • nfq/Makefile - Network filtering

Installation & Detection

  • install_bin.sh - Binary installation
  • install_easy.sh - Easy installer
  • .github/workflows/build.yml - CI/CD pipeline

New Files

  • scripts/macos_arch_detect.sh - Architecture utility
  • scripts/test_macos_arch.sh - Test script
  • docs/MACOS_REFACTORING.md - Comprehensive guide
  • CHANGELOG_MACOS_REFACTORING.md - Detailed changes

🔧 How It Works

  1. Detection: Scripts automatically detect MacOS architecture
  2. Target Setting: Appropriate compilation targets are set
  3. Compilation: Code compiles for detected architecture
  4. Installation: Correct binaries are installed automatically

📋 Requirements

  • Minimum: macOS 10.8 (Mountain Lion)
  • Recommended: macOS 11+ (Big Sur)
  • Tools: Xcode Command Line Tools or clang

🧪 Testing

# Test architecture detection
./scripts/test_macos_arch.sh

# Test build system
make mac
make mac-universal

# Test utility script
./scripts/macos_arch_detect.sh detect
./scripts/macos_arch_detect.sh build

📚 Documentation

  • Quick Start: This file
  • Comprehensive Guide: docs/MACOS_REFACTORING.md
  • Change Details: CHANGELOG_MACOS_REFACTORING.md
  • Original README: docs/readme.en.md

🎉 Benefits

  • No Manual Configuration - Works out of the box
  • Cross-Architecture - Supports both Intel and Apple Silicon
  • Universal Binaries - Single binary for both architectures
  • Better Performance - Architecture-specific optimizations
  • Easier Development - Simplified build process
  • CI/CD Integration - Automated testing for both architectures

🔮 Future Plans

  • Support for newer MacOS versions
  • Performance benchmarking tools
  • Cross-compilation from Linux
  • Automated architecture testing

🤝 Contributing

The refactoring is complete and ready for use. All changes are backward compatible. Existing installations will continue to work without modification.

📞 Support

For issues or questions related to MacOS support:

  1. Check the documentation in docs/MACOS_REFACTORING.md
  2. Run the test script: ./scripts/test_macos_arch.sh
  3. Review the changelog: CHANGELOG_MACOS_REFACTORING.md

Status: Complete and Ready for Production Compatibility: Backward Compatible Architectures: x86_64, arm64, Universal