Skip to content

Commit be564ea

Browse files
[Tool] Photon v0.1.0
- Cross platform build tool for Noviq.
1 parent 5d579ad commit be564ea

10 files changed

Lines changed: 1199 additions & 21 deletions

File tree

.github/workflows/build-photon.yml

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
name: Build Photon
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
paths:
7+
- 'photon/**'
8+
- '.github/workflows/build-photon.yml'
9+
pull_request:
10+
branches: [ main ]
11+
paths:
12+
- 'photon/**'
13+
workflow_dispatch:
14+
15+
env:
16+
CARGO_TERM_COLOR: always
17+
18+
jobs:
19+
build:
20+
name: Build Photon - ${{ matrix.os }}
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
include:
25+
- os: ubuntu-latest
26+
target: x86_64-unknown-linux-gnu
27+
artifact_name: photon
28+
asset_name: photon-linux-x86_64
29+
- os: windows-latest
30+
target: x86_64-pc-windows-msvc
31+
artifact_name: photon.exe
32+
asset_name: photon-windows-x86_64.exe
33+
- os: macos-latest
34+
target: x86_64-apple-darwin
35+
artifact_name: photon
36+
asset_name: photon-macos-x86_64
37+
- os: macos-latest
38+
target: aarch64-apple-darwin
39+
artifact_name: photon
40+
asset_name: photon-macos-aarch64
41+
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v4
45+
46+
- name: Setup Rust toolchain
47+
uses: dtolnay/rust-toolchain@stable
48+
with:
49+
targets: ${{ matrix.target }}
50+
51+
- name: Cache cargo registry
52+
uses: actions/cache@v4
53+
with:
54+
path: ~/.cargo/registry
55+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
56+
57+
- name: Cache cargo index
58+
uses: actions/cache@v4
59+
with:
60+
path: ~/.cargo/git
61+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
62+
63+
- name: Cache cargo build
64+
uses: actions/cache@v4
65+
with:
66+
path: photon/target
67+
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
68+
69+
- name: Build Photon
70+
working-directory: photon
71+
run: cargo build --release --target ${{ matrix.target }}
72+
73+
- name: Run tests
74+
working-directory: photon
75+
run: cargo test --release --target ${{ matrix.target }}
76+
77+
- name: Strip binary (Linux and macOS)
78+
if: matrix.os != 'windows-latest'
79+
working-directory: photon
80+
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
81+
82+
- name: Rename binary
83+
working-directory: photon
84+
shell: bash
85+
run: |
86+
mkdir -p artifacts
87+
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} artifacts/${{ matrix.asset_name }}
88+
89+
- name: Upload artifact
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: ${{ matrix.asset_name }}
93+
path: photon/artifacts/${{ matrix.asset_name }}
94+
if-no-files-found: error
95+
96+
build-info:
97+
name: Build Information
98+
runs-on: ubuntu-latest
99+
needs: build
100+
steps:
101+
- name: Checkout repository
102+
uses: actions/checkout@v4
103+
104+
- name: Get Photon version
105+
id: version
106+
working-directory: photon
107+
run: |
108+
VERSION=$(grep '^version = ' Cargo.toml | head -1 | cut -d'"' -f2)
109+
echo "version=$VERSION" >> $GITHUB_OUTPUT
110+
echo "Photon version: $VERSION"
111+
112+
- name: Create build info
113+
run: |
114+
cat > build-info.txt << EOF
115+
Photon Build Information
116+
========================
117+
Version: ${{ steps.version.outputs.version }}
118+
Commit: ${{ github.sha }}
119+
Branch: ${{ github.ref_name }}
120+
Build Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
121+
Workflow: ${{ github.workflow }}
122+
Run Number: ${{ github.run_number }}
123+
124+
Available Artifacts:
125+
- photon-linux-x86_64 (Linux x86_64)
126+
- photon-windows-x86_64.exe (Windows x86_64)
127+
- photon-macos-x86_64 (macOS Intel)
128+
- photon-macos-aarch64 (macOS Apple Silicon)
129+
130+
Repository: ${{ github.repository }}
131+
Actor: ${{ github.actor }}
132+
EOF
133+
cat build-info.txt
134+
135+
- name: Upload build info
136+
uses: actions/upload-artifact@v4
137+
with:
138+
name: build-info
139+
path: build-info.txt
140+
141+
create-release-archive:
142+
name: Create Release Archive
143+
runs-on: ubuntu-latest
144+
needs: build
145+
steps:
146+
- name: Download all artifacts
147+
uses: actions/download-artifact@v4
148+
with:
149+
path: artifacts
150+
151+
- name: Display structure
152+
run: ls -R artifacts
153+
154+
- name: Create combined archive
155+
run: |
156+
cd artifacts
157+
# Move binaries to root level
158+
find . -type f -name "photon*" -exec mv {} . \;
159+
# Remove empty directories
160+
find . -type d -empty -delete
161+
# Create archive
162+
tar -czf photon-all-platforms.tar.gz photon-*
163+
zip -r photon-all-platforms.zip photon-*
164+
165+
- name: Upload combined archive (tar.gz)
166+
uses: actions/upload-artifact@v4
167+
with:
168+
name: photon-all-platforms-tar
169+
path: artifacts/photon-all-platforms.tar.gz
170+
171+
- name: Upload combined archive (zip)
172+
uses: actions/upload-artifact@v4
173+
with:
174+
name: photon-all-platforms-zip
175+
path: artifacts/photon-all-platforms.zip

.github/workflows/build.yml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -115,24 +115,4 @@ jobs:
115115
shell: bash
116116
run: |
117117
ls -lh artifacts/
118-
file artifacts/${{ steps.artifact.outputs.name }} || true
119-
120-
release:
121-
name: Create Release
122-
needs: build
123-
runs-on: ubuntu-latest
124-
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/Rust-reimpl')
125-
126-
steps:
127-
- name: Download all artifacts
128-
uses: actions/download-artifact@v4
129-
with:
130-
path: artifacts
131-
132-
- name: Display downloaded artifacts
133-
run: |
134-
ls -R artifacts/
135-
136-
- name: Get current date
137-
id: date
138-
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
118+
file artifacts/${{ steps.artifact.outputs.name }} || true

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
/target/
33
Cargo.lock
44

5+
# Photon build artifacts
6+
/photon/target/
7+
/photon/Cargo.lock
8+
59
# Build outputs
610
/libs/
711

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,36 @@ A language written to have an easy syntax and high performance.
1818

1919
Noviq aims to be a compiled language instead of an interpreted language in the future.
2020

21+
Builder tool for interpreter version is called: Photon or Photon-NVQ
22+
The compiler will be called: Singularity or Singularity-NVQ
23+
2124
## Building
2225

26+
### Using Photon (Recommended)
27+
28+
Photon is the official build tool for Noviq, providing a unified cross-platform build experience:
29+
30+
```bash
31+
# Build Photon first
32+
cd photon
33+
cargo build --release
34+
35+
# Use Photon to build Noviq
36+
./target/release/photon build # Debug build
37+
./target/release/photon build release # Release build
38+
./target/release/photon build snapshot # Snapshot build with git hash
39+
40+
# Install binaries to libs/
41+
./target/release/photon install
42+
43+
# Clean build artifacts
44+
./target/release/photon clean
45+
```
46+
47+
See [photon/README.md](photon/README.md) for more details.
48+
49+
### Using Build Scripts (Legacy)
50+
2351
```bash
2452
./build.sh # Debug build
2553
./build.sh --release # Release build

photon/Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "photon"
3+
version = "0.1.0"
4+
edition = "2021"
5+
description = "Build tool for the Noviq programming language"
6+
authors = ["Noviq Contributors"]
7+
8+
[[bin]]
9+
name = "photon"
10+
path = "src/main.rs"
11+
12+
[dependencies]
13+
chrono = "0.4"
14+
15+
[profile.release]
16+
opt-level = 3
17+
lto = true
18+
codegen-units = 1
19+
strip = true

0 commit comments

Comments
 (0)