Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,46 @@ jobs:
runs-on: ubuntu-latest

steps:
# 1. Checkout Code
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# 2. Set up Rust
- name: Set up Rust (nightly)
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
components: rustc, rust-src, cargo
components: rustc-dev llvm-tools cargo

# 4. Set up Java
- name: Set up Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

# 5. Set up Python
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'

# 6. Set up Gradle
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y make

- name: Build all components
run: make all

# 7. Make just the files needed to cargo cache
- name: Make Gen Files
run: make gen-files

# 8. Cargo Caching (Crucial for speed)
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2

# 9. Build using the CI-specific make target
- name: Build CI Target
run: make ci # Use your optimized CI build command

# 10. Run tests
- name: Run integration tests
run: python3 Tester.py

- name: Cleanup
if: always() # Ensure cleanup runs even if previous steps failed
run: make clean
run: python3 Tester.py
50 changes: 44 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# === Phony Targets ===
.PHONY: all help clean rust-components rust clean-rust java-linker clean-java-linker \
shim-metadata-gen clean-shim-metadata-gen asm-processor clean-asm-processor \
library clean-library gen-files clean-gen-files
library clean-library gen-files clean-gen-files ci

# === Terminal Colors ===
GREEN := \033[1;32m
Expand All @@ -16,15 +16,25 @@ LIBRARY_DIR := library
LIBRARY_JAR := $(LIBRARY_DIR)/build/libs/library-0.1.0.jar

# === Default Target ===
ifeq ($(IS_CI),1)
all: rust java-linker asm-processor
@echo "$(GREEN)✨ Build complete in CI mode! ✨$(RESET)"
else
all: rust gen-files java-linker asm-processor
@echo "$(GREEN)✨ Build complete! ✨$(RESET)"
endif

# === CI Target ===
ci:
$(MAKE) all IS_CI=1

# === Help ===
help:
@echo "$(CYAN)🛠️ Makefile for building the project$(RESET)"
@echo ""
@echo "Available targets:"
@echo " make all - Build all components"
@echo " make ci - Build all components in CI mode (skips rust-components and shim-metadata-gen)"
@echo " make clean - Clean all components"
@echo " make rust-components - Install needed Rust components"
@echo " make rust - Build the Rust root project"
Expand All @@ -38,12 +48,18 @@ help:
# === Needed rust components ===
rust-components:
@echo "$(CYAN)🔧 Installing Rust components...$(RESET)"
rustup component add rust-src rustc-dev llvm-tools-preview
rustup component add rustc-dev llvm-tools

# === Rust root project (Cargo) ===
ifeq ($(IS_CI),1)
rust: $(SHIM_METADATA_GEN_DIR)/core.json
@echo "$(CYAN)📦 Building Rust root project...$(RESET)"
cargo build
else
rust: $(SHIM_METADATA_GEN_DIR)/core.json rust-components
@echo "$(CYAN)📦 Building Rust root project...$(RESET)"
cargo build
endif

clean-rust:
@echo "$(CYAN)🧹 Cleaning Rust root project...$(RESET)"
Expand All @@ -60,8 +76,14 @@ clean-java-linker:

# === Library Shim Metadata Generator ===
$(SHIM_METADATA_GEN_DIR)/core.json: library
@echo "$(CYAN)🛠️ Generating library shim metadata...$(RESET)"
cd $(SHIM_METADATA_GEN_DIR) && cargo run -- ../$(LIBRARY_JAR) ./core.json
@if [ "$(IS_CI)" = "1" ]; then \
echo "$(CYAN)CI mode: skipping shim-metadata-gen$(RESET)"; \
elif [ -f $@ ]; then \
echo "$(CYAN)core.json already exists, skipping shim-metadata-gen$(RESET)"; \
else \
echo "$(CYAN)🛠️ Generating library shim metadata...$(RESET)"; \
cd $(SHIM_METADATA_GEN_DIR) && cargo run -- ../$(LIBRARY_JAR) ./core.json; \
fi

clean-shim-metadata-gen:
@echo "$(CYAN)🧹 Cleaning shim-metadata-gen...$(RESET)"
Expand All @@ -71,24 +93,40 @@ clean-shim-metadata-gen:
# === ASM Processor (Gradle) ===
asm-processor:
@echo "$(CYAN)⚙️ Building ASM processor...$(RESET)"
ifeq ($(IS_CI),1)
cd $(ASM_PROCESSOR_DIR) && gradle --no-daemon shadowJar
else
cd $(ASM_PROCESSOR_DIR) && gradle shadowJar
endif

clean-asm-processor:
@echo "$(CYAN)🧹 Cleaning ASM processor...$(RESET)"
ifeq ($(IS_CI),1)
cd $(ASM_PROCESSOR_DIR) && gradle --no-daemon clean
else
cd $(ASM_PROCESSOR_DIR) && gradle clean
endif

# === Standard Library Shim (Gradle) ===
library: $(LIBRARY_JAR)

$(LIBRARY_JAR):
@echo "$(CYAN)📚 Building standard library shim...$(RESET)"
ifeq ($(IS_CI),1)
cd $(LIBRARY_DIR) && gradle --no-daemon build && cd build/distributions && unzip -o library-0.1.0.zip
else
cd $(LIBRARY_DIR) && gradle build && cd build/distributions && unzip -o library-0.1.0.zip
endif

clean-library:
@echo "$(CYAN)🧹 Cleaning library shim...$(RESET)"
ifeq ($(IS_CI),1)
cd $(LIBRARY_DIR) && gradle --no-daemon clean
else
cd $(LIBRARY_DIR) && gradle clean
endif

# === Generate files from templates ==
# === Generate files from templates ===
gen-files: clean-gen-files
@echo "$(CYAN)🛠️ Generating files from templates...$(RESET)"
python3 GenerateFiles.py
Expand All @@ -100,4 +138,4 @@ clean-gen-files:

# === Clean All ===
clean: clean-rust clean-java-linker clean-asm-processor clean-library clean-shim-metadata-gen clean-gen-files
@echo "$(GREEN)🧼 All clean!$(RESET)"
@echo "$(GREEN)🧼 All clean!$(RESET)"
Loading