# Binary Distribution Guide
## Quick Answer
✅ **YES, you can distribute the compiled binary without source code!**
All dependencies use permissive licenses (Apache-2.0, MIT, BSD, ISC) that allow closed-source binary distribution.
## What You Need to Include
### 1. Your Binary
```
multi_lang_profiler # or multi_lang_profiler.exe on Windows
```
### 2. License Files (Required)
Create a `LICENSES/` directory with:
```
LICENSES/
├── LICENSE-APACHE # Apache-2.0 full text
├── LICENSE-MIT # MIT full text
└── THIRD-PARTY-NOTICES # List of all dependencies
```
### 3. Generate License Files
```bash
# Download license texts
curl https://www.apache.org/licenses/LICENSE-2.0.txt -o LICENSES/LICENSE-APACHE
curl https://opensource.org/licenses/MIT -o LICENSES/LICENSE-MIT
# Generate third-party notices
cargo license --authors --do-not-bundle > LICENSES/THIRD-PARTY-NOTICES
```
## Distribution Package Structure
### Minimal Distribution
```
my-profiler/
├── multi_lang_profiler # Binary
└── LICENSES/
├── LICENSE-APACHE
├── LICENSE-MIT
└── THIRD-PARTY-NOTICES
```
### Complete Distribution
```
my-profiler/
├── bin/
│ └── multi_lang_profiler # Binary
├── LICENSES/
│ ├── LICENSE-APACHE
│ ├── LICENSE-MIT
│ └── THIRD-PARTY-NOTICES
├── docs/
│ ├── README.md # Usage instructions
│ └── LICENSE_ANALYSIS.md # License details
└── examples/ # Optional examples
```
## License Summary
### Direct Dependencies (What You Use)
| regex | Apache-2.0 OR MIT | ✅ Yes |
| serde | Apache-2.0 OR MIT | ✅ Yes |
| serde_json | Apache-2.0 OR MIT | ✅ Yes |
| chrono | Apache-2.0 OR MIT | ✅ Yes |
| py-spy | MIT | ✅ Yes |
**Result:** All permissive licenses - binary distribution allowed!
### All Dependencies (245 packages)
- **149 packages:** Apache-2.0 OR MIT
- **33 packages:** MIT
- **6 packages:** MIT OR Unlicense
- **Other:** Various permissive (BSD, ISC, etc.)
- **0 packages:** GPL, LGPL, AGPL, or other copyleft
## What You CAN Do
✅ **Distribute compiled binaries** without source code
✅ **Sell the software** commercially
✅ **Keep modifications private** and proprietary
✅ **Static link** all dependencies
✅ **Modify and redistribute** as closed-source
✅ **Use in proprietary products**
✅ **Deploy as SaaS** without source disclosure
## What You MUST Do
### Required:
1. ✅ Include Apache-2.0 license text
2. ✅ Include MIT license text
3. ✅ List third-party dependencies with their licenses
4. ✅ Preserve copyright notices
### Optional but Recommended:
- 📝 Add your own copyright notice
- 📝 Document which dependencies are used
- 📝 Provide attribution in About/Help dialogs
- 📝 Link to dependency repositories
## What You DON'T Need to Do
❌ **Provide source code** of the profiler
❌ **Provide source code** of dependencies
❌ **Make modifications open source**
❌ **Publish build instructions**
❌ **Notify anyone** about distribution
❌ **Request permission** from dependency authors
❌ **Pay royalties or fees**
## Platform-Specific Notes
### Linux
```bash
# Build release binary
cargo build --release
# Strip debug symbols (optional, reduces size)
strip target/release/multi_lang_profiler
# Package
mkdir -p dist/LICENSES
cp target/release/multi_lang_profiler dist/
cp LICENSES/* dist/LICENSES/
tar czf profiler-linux-x64.tar.gz -C dist .
```
### macOS
```bash
# Build release binary
cargo build --release
# Sign the binary (optional)
codesign -s "Developer ID" target/release/multi_lang_profiler
# Package
mkdir -p dist/LICENSES
cp target/release/multi_lang_profiler dist/
cp LICENSES/* dist/LICENSES/
tar czf profiler-macos-arm64.tar.gz -C dist .
```
### Windows
```powershell
# Build release binary
cargo build --release
# Package
mkdir dist\LICENSES
copy target\release\multi_lang_profiler.exe dist\
copy LICENSES\* dist\LICENSES\
Compress-Archive -Path dist\* -DestinationPath profiler-windows-x64.zip
```
## Docker Distribution
```dockerfile
# Multi-stage build
FROM rust:latest AS builder
WORKDIR /app
COPY . .
RUN cargo build --release
FROM debian:bookworm-slim
WORKDIR /app
# Copy binary and licenses
COPY --from=builder /app/target/release/multi_lang_profiler /usr/local/bin/
COPY --from=builder /app/LICENSES /usr/share/licenses/profiler/
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
python3 \
openjdk-17-jre \
nodejs \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["multi_lang_profiler"]
```
## Cloud Distribution (AWS, Azure, GCP)
### AWS Lambda Layer
```bash
# Build for AWS Lambda (Amazon Linux 2)
cargo build --release --target x86_64-unknown-linux-musl
# Create layer
mkdir -p layer/bin layer/LICENSES
cp target/x86_64-unknown-linux-musl/release/multi_lang_profiler layer/bin/
cp LICENSES/* layer/LICENSES/
cd layer && zip -r ../profiler-layer.zip .
# Upload to AWS Lambda
aws lambda publish-layer-version \
--layer-name profiler \
--zip-file fileb://profiler-layer.zip
```
## Commercial Use Cases
### ✅ Allowed Without Restrictions:
1. **SaaS Product**
- Run profiler as backend service
- Charge customers for profiling
- No source code disclosure required
2. **Desktop Application**
- Bundle profiler with your app
- Sell commercially
- Keep modifications private
3. **CI/CD Tool**
- Integrate into build pipelines
- Sell as enterprise tool
- Distribute binaries only
4. **Consulting/Services**
- Use in client projects
- Customize for clients
- Deliver as binary only
5. **OEM/Embedded**
- Bundle with hardware
- Include in firmware
- No source disclosure needed
## Compliance Checklist
Before distribution, verify:
- [ ] Built release binary (`cargo build --release`)
- [ ] Stripped debug symbols (optional, for size)
- [ ] Included LICENSE-APACHE file
- [ ] Included LICENSE-MIT file
- [ ] Generated THIRD-PARTY-NOTICES file
- [ ] Tested binary works standalone
- [ ] Added your own copyright notice (optional)
- [ ] Created distribution package
- [ ] Tested on target platforms
## Automated Compliance
### CI/CD Integration
```yaml
# .github/workflows/release.yml
name: Release Build
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build release
run: cargo build --release
- name: Generate licenses
run: |
mkdir -p dist/LICENSES
cargo install cargo-license
cargo license --authors > dist/LICENSES/THIRD-PARTY-NOTICES
- name: Package
run: |
cp target/release/multi_lang_profiler dist/
cp LICENSES/* dist/LICENSES/
tar czf profiler-linux-x64.tar.gz -C dist .
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: profiler-linux-x64
path: profiler-linux-x64.tar.gz
```
### License Checking
```bash
# Install cargo-deny
cargo install cargo-deny
# Check for problematic licenses
cargo deny check licenses
# This will fail if GPL/AGPL/LGPL dependencies are added
```
## Questions & Answers
### Q: Can I sell this software?
**A:** Yes! All licenses permit commercial use.
### Q: Do I need to provide source code?
**A:** No. Apache-2.0 and MIT don't require source disclosure.
### Q: Can I modify it and keep changes private?
**A:** Yes. You can make proprietary modifications.
### Q: What about py-spy dependency?
**A:** py-spy is MIT licensed - fully permissive, no restrictions.
### Q: Can I remove license files from the binary?
**A:** No. You must include license texts when distributing.
### Q: Can I use this in a proprietary product?
**A:** Yes! All dependencies allow proprietary use.
### Q: Do I need to contribute changes back?
**A:** No. Neither Apache-2.0 nor MIT require this.
### Q: Can I static link everything?
**A:** Yes. Rust statically links by default, no issues.
### Q: What about patent grants?
**A:** Apache-2.0 includes patent grant. MIT doesn't mention patents but implies permission.
### Q: Can I rebrand/white-label it?
**A:** Yes, but you must include original license files and attributions.
## Support & Resources
- License texts: [LICENSES/](LICENSES/)
- Full analysis: [LICENSE_ANALYSIS.md](LICENSE_ANALYSIS.md)
- Apache-2.0: https://www.apache.org/licenses/LICENSE-2.0
- MIT: https://opensource.org/licenses/MIT
- cargo-license: https://github.com/onur/cargo-license
- cargo-deny: https://github.com/EmbarkStudios/cargo-deny
## Legal Disclaimer
This guide is provided for informational purposes. For legal advice specific to your situation, consult with a qualified attorney. The information here is based on common understanding of the mentioned licenses as of 2025.
## Summary
✅ **You're good to go!**
All dependencies use permissive licenses. You can:
- Distribute binaries without source
- Use commercially
- Keep modifications private
- Static link everything
Just remember to include the license files!