Skip to content

Commit

Permalink
chore: add Makefile
Browse files Browse the repository at this point in the history
Update README.md
Update gitignore
  • Loading branch information
arttet committed Dec 8, 2023
1 parent f0eae3c commit 0bb2126
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 14 deletions.
15 changes: 2 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/
rust

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
Makefile.local
78 changes: 78 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
RUST_PREBUILT_VERSION ?= 2023-11-13
RUST_PREBUILT_COMPONENTS ?= rust-std rustc cargo rustfmt
RUST_PREBUILT_CHANNELS ?= beta nightly
RUST_PREBUILT_TARGET ?= x86_64-apple-darwin
RUST_PREBUILT_OUTPUT_DIR ?= rust/build/cache

RUST_GIT_URL ?= https://github.com/rust-lang/rust.git
RUST_TOOLS ?= cargo,clippy,rustdoc,rustfmt,rust-analyzer,analysis,src
RUST_TARGETS ?= aarch64-apple-ios,aarch64-apple-darwin
RUST_VERBOSE ?= 0
RUST_CHANNEL ?= dev
RUST_DESCRIPTION ?= ""
RUST_INSTALL_DIR ?= install
RUST_DIST_FORMATS ?= xz

# NOTE: use Makefile.local for customization
-include Makefile.local

.PHONY: help
help: ## Show this help
@fgrep -h "## " $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

.PHONY: download
download: ## Download Rust sources
git clone --recurse-submodules -j8 ${RUST_GIT_URL}

.PHONY: download-offline
download-offline: SHELL:=/bin/bash
download-offline: ## Download prebuilt Rust binaries
mkdir -p ${RUST_PREBUILT_OUTPUT_DIR}/${RUST_PREBUILT_VERSION}
@for RUST_CHANNEL in ${RUST_PREBUILT_CHANNELS}; do \
for RUST_COMPONENT in ${RUST_PREBUILT_COMPONENTS}; do \
RUST_FILENAME=${RUST_PREBUILT_VERSION}/$${RUST_COMPONENT}-$${RUST_CHANNEL}-${RUST_PREBUILT_TARGET}.tar.xz ; \
curl --fail https://static.rust-lang.org/dist/$${RUST_FILENAME} --output ${RUST_PREBUILT_OUTPUT_DIR}/$${RUST_FILENAME} ; \
done; \
done;

###
# Configure: https://github.com/rust-lang/rust/blob/master/src/bootstrap/configure.py
###

.PHONY: configure
configure: ## Configure Rust
cd rust && ./configure \
--enable-option-checking \
--enable-verbose-tests \
--enable-codegen-tests \
--enable-dist-src \
--tools=${RUST_TOOLS} \
--target=${RUST_TARGETS} \
--set llvm.download-ci-llvm=true \
--set build.verbose=${RUST_VERBOSE} \
--set rust.channel=${RUST_CHANNEL} \
--set rust.description=${RUST_DESCRIPTION} \
--dist-compression-formats=${RUST_DIST_FORMATS} \
--prefix=${RUST_INSTALL_DIR}

.PHONY: configure-offline
configure-offline: ## Configure Rust and LLVM
cd rust && ./configure \
--enable-option-checking \
--enable-sccache \
--enable-ninja \
--enable-verbose-tests \
--enable-codegen-tests \
--enable-dist-src \
--tools=${RUST_TOOLS} \
--target=${RUST_TARGETS} \
--set llvm.download-ci-llvm=false \
--set llvm.targets="AArch64;X86" \
--set llvm.experimental-targets="" \
--set llvm.tests=true \
--set build.verbose=${RUST_VERBOSE} \
--set rust.channel=${RUST_CHANNEL} \
--set rust.description=${RUST_DESCRIPTION} \
--set rust.omit-git-hash=true \
--dist-compression-formats=${RUST_DIST_FORMATS} \
--prefix=${RUST_INSTALL_DIR}
4 changes: 4 additions & 0 deletions Makefile.example.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# RUST_TOOLS = cargo,rustfmt
# RUST_TARGETS = arm64e-apple-ios,arm64e-apple-darwin
# RUST_CHANNEL = stable
# RUST_VERBOSE = 3
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
# rust-builder
# Rust Compiler Builder

[![Rust](https://img.shields.io/badge/Rust-Dev-orange.svg)](https://github.com/rust-lang/rust)

Builds the *Rust* compiler and [Tier 3 targets](https://doc.rust-lang.org/nightly/rustc/platform-support.html) using *GitHub Actions*.

## Usage

```sh
$ make
help: Show this help
download: Download Rust sources
download-offline: Download prebuilt Rust binaries
configure: Configure Rust
configure-offline: Configure Rust and LLVM
```

0 comments on commit 0bb2126

Please sign in to comment.