|
| 1 | +# GitHub Workflows for Building MP4v2 |
| 2 | + |
| 3 | +This directory contains GitHub Actions workflows for building the MP4v2 library for various platforms. |
| 4 | + |
| 5 | +## Available Workflows |
| 6 | + |
| 7 | +### 1. `build-mp4v2-linux-arm64.yml` |
| 8 | +**Purpose:** Build MP4v2 for Linux ARM64 using Autotools |
| 9 | + |
| 10 | +**Features:** |
| 11 | +- Uses QEMU for ARM64 emulation on x86_64 runners |
| 12 | +- Builds with GNU Autotools (./configure && make) |
| 13 | +- Automatically commits built libraries to the repository |
| 14 | +- Uploads artifacts for download |
| 15 | + |
| 16 | +**Triggers:** |
| 17 | +- Push to `main` or `master` branches |
| 18 | +- Pull requests |
| 19 | +- Manual workflow dispatch |
| 20 | + |
| 21 | +**Output:** |
| 22 | +- Static library: `Linux/arm64/libmp4v2.a` |
| 23 | +- Shared libraries: `Linux/arm64/libmp4v2.so*` (if built) |
| 24 | +- Headers: `include/mp4v2/` |
| 25 | + |
| 26 | +**Usage:** |
| 27 | +```bash |
| 28 | +# Triggered automatically on push, or run manually: |
| 29 | +# 1. Go to Actions tab |
| 30 | +# 2. Select "Build MP4v2 for Linux ARM64" |
| 31 | +# 3. Click "Run workflow" |
| 32 | +``` |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +### 2. `build-mp4v2-cmake.yml` |
| 37 | +**Purpose:** Build MP4v2 for multiple platforms using CMake |
| 38 | + |
| 39 | +**Features:** |
| 40 | +- Supports Linux ARM64 and Linux x64 |
| 41 | +- Uses CMake build system for more flexibility |
| 42 | +- Configurable platform selection via workflow inputs |
| 43 | +- Longer artifact retention (90 days) |
| 44 | +- Separate jobs for each platform |
| 45 | + |
| 46 | +**Triggers:** |
| 47 | +- Push to `main` or `master` branches (ARM64 only) |
| 48 | +- Pull requests (ARM64 only) |
| 49 | +- Manual workflow dispatch with platform selection |
| 50 | + |
| 51 | +**Output:** |
| 52 | +- Linux ARM64: `Linux/arm64/libmp4v2.a` |
| 53 | +- Linux x64: `Linux/x64/libmp4v2.a` (manual trigger only) |
| 54 | +- Headers: `include/mp4v2/` |
| 55 | + |
| 56 | +**Usage:** |
| 57 | +```bash |
| 58 | +# Manual trigger with options: |
| 59 | +# 1. Go to Actions tab |
| 60 | +# 2. Select "Build MP4v2 (CMake) for Multiple Platforms" |
| 61 | +# 3. Click "Run workflow" |
| 62 | +# 4. Enter platforms: "linux-arm64", "linux-x64", or "all" |
| 63 | +``` |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## Workflow Comparison |
| 68 | + |
| 69 | +| Feature | build-mp4v2-linux-arm64.yml | build-mp4v2-cmake.yml | |
| 70 | +|---------|-----------------------------|-----------------------| |
| 71 | +| Build System | Autotools | CMake | |
| 72 | +| Platforms | Linux ARM64 | Linux ARM64, x64 | |
| 73 | +| Auto Commit | Yes | No | |
| 74 | +| Artifact Retention | 30 days | 90 days | |
| 75 | +| Platform Selection | No | Yes (workflow_dispatch) | |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +## Common Tasks |
| 80 | + |
| 81 | +### Building for Linux ARM64 |
| 82 | +Both workflows can build for Linux ARM64. The differences: |
| 83 | +- **Autotools workflow**: More traditional Unix build approach, auto-commits |
| 84 | +- **CMake workflow**: Modern build system, more control, no auto-commit |
| 85 | + |
| 86 | +### Downloading Artifacts |
| 87 | +After a workflow completes: |
| 88 | +1. Go to the workflow run page |
| 89 | +2. Scroll to the **Artifacts** section |
| 90 | +3. Download the ZIP file (e.g., `mp4v2-linux-arm64.zip`) |
| 91 | +4. Extract and copy files to your project |
| 92 | + |
| 93 | +### Modifying Build Options |
| 94 | + |
| 95 | +**For Autotools workflow**, edit the `./configure` line: |
| 96 | +```bash |
| 97 | +./configure --prefix=/build/install --enable-static --disable-shared |
| 98 | +``` |
| 99 | + |
| 100 | +**For CMake workflow**, edit the `cmake` command: |
| 101 | +```bash |
| 102 | +cmake .. \ |
| 103 | + -DCMAKE_BUILD_TYPE=Release \ |
| 104 | + -DBUILD_SHARED_LIBS=OFF \ |
| 105 | + -DCMAKE_CXX_FLAGS="-O3" |
| 106 | +``` |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +## Technical Details |
| 111 | + |
| 112 | +### QEMU Setup |
| 113 | +Both workflows use QEMU for ARM64 emulation: |
| 114 | +```yaml |
| 115 | +- name: Set up QEMU |
| 116 | + uses: docker/setup-qemu-action@v3 |
| 117 | + with: |
| 118 | + platforms: arm64 |
| 119 | +``` |
| 120 | +
|
| 121 | +This allows building ARM64 binaries on x86_64 GitHub runners. |
| 122 | +
|
| 123 | +### Docker Container |
| 124 | +ARM64 builds run in an `arm64v8/ubuntu:22.04` container: |
| 125 | +```bash |
| 126 | +docker run --rm --platform linux/arm64 \ |
| 127 | + -v ${{ github.workspace }}:/workspace \ |
| 128 | + arm64v8/ubuntu:22.04 bash -c "..." |
| 129 | +``` |
| 130 | + |
| 131 | +### Verification |
| 132 | +After building, workflows verify the architecture: |
| 133 | +```bash |
| 134 | +file Linux/arm64/libmp4v2.a |
| 135 | +# Output: Linux/arm64/libmp4v2.a: current ar archive |
| 136 | +``` |
| 137 | + |
| 138 | +--- |
| 139 | + |
| 140 | +## Troubleshooting |
| 141 | + |
| 142 | +### Build Fails with "No such file or directory" |
| 143 | +- Check that the git clone succeeded |
| 144 | +- Verify the repository URL is correct |
| 145 | +- Ensure network connectivity during workflow run |
| 146 | + |
| 147 | +### Wrong Architecture Built |
| 148 | +- Verify `--platform linux/arm64` is set in docker run command |
| 149 | +- Check QEMU setup completed successfully |
| 150 | +- Run `file` command on the artifact to verify architecture |
| 151 | + |
| 152 | +### Artifact Not Found |
| 153 | +- Check the output path matches the artifact path in the workflow |
| 154 | +- Verify the build completed successfully |
| 155 | +- Check that `make install` or copy commands succeeded |
| 156 | + |
| 157 | +### Auto-commit Fails |
| 158 | +- Ensure the workflow has write permissions to the repository |
| 159 | +- Check that git config is set correctly |
| 160 | +- Verify `[skip ci]` is in the commit message to prevent infinite loops |
| 161 | + |
| 162 | +--- |
| 163 | + |
| 164 | +## Adding New Platforms |
| 165 | + |
| 166 | +To add support for a new platform (e.g., Windows ARM64): |
| 167 | + |
| 168 | +1. Create a new job in the workflow: |
| 169 | +```yaml |
| 170 | +build-windows-arm64: |
| 171 | + runs-on: windows-latest |
| 172 | + steps: |
| 173 | + - name: Checkout |
| 174 | + uses: actions/checkout@v4 |
| 175 | + # Add Windows-specific build steps |
| 176 | +``` |
| 177 | + |
| 178 | +2. Use appropriate tools for that platform: |
| 179 | + - Windows: Visual Studio, vcpkg |
| 180 | + - macOS: Xcode command line tools |
| 181 | + - Android: NDK |
| 182 | + |
| 183 | +3. Update artifact paths to match your repository structure |
| 184 | + |
| 185 | +--- |
| 186 | + |
| 187 | +## Resources |
| 188 | + |
| 189 | +- **MP4v2 Repository:** https://github.com/enzo1982/mp4v2 |
| 190 | +- **GitHub Actions Documentation:** https://docs.github.com/en/actions |
| 191 | +- **Docker QEMU Setup:** https://github.com/docker/setup-qemu-action |
| 192 | +- **Upload Artifacts:** https://github.com/actions/upload-artifact |
| 193 | + |
0 commit comments