Skip to content

Commit b7b2420

Browse files
authored
refactor: restructure Makefile for better readability (#17)
- Removed redundant targets - Grouped related tasks together
1 parent e5ca42e commit b7b2420

File tree

4 files changed

+35
-25
lines changed

4 files changed

+35
-25
lines changed

.github/workflows/rust-compiler-builder.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ on:
77
- '**/README.md'
88
schedule:
99
# https://crontab.guru/
10-
# At 12:00 AM, only on Monday
11-
- cron: 0 0 * * 1
10+
# At 12:00 AM
11+
- cron: 0 0 * * *
1212

1313
jobs:
1414
build:
@@ -68,7 +68,7 @@ jobs:
6868
6969
- name: Show System Info
7070
run: |
71-
echo $PATH
71+
echo ${PATH}
7272
uname -a
7373
xcodebuild -version
7474
xcrun --show-sdk-path
@@ -97,6 +97,10 @@ jobs:
9797
RUST_VERBOSE: ${{ matrix.rust-verbose-level }}
9898
RUST_USE_LLD: ${{ matrix.rust-use-lld }}
9999

100+
- name: Show config.toml
101+
run: cat config.toml
102+
working-directory: ./rust
103+
100104
- name: Build Rust
101105
run: make all
102106
working-directory: ./rust

Makefile

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
RUST_PREBUILT_VERSION ?= 2023-11-13
2-
RUST_PREBUILT_COMPONENTS ?= rust-std rustc cargo rustfmt
3-
RUST_PREBUILT_CHANNELS ?= beta nightly
4-
RUST_PREBUILT_TARGET ?= x86_64-apple-darwin
5-
RUST_PREBUILT_OUTPUT_DIR ?= rust/build/cache
6-
71
RUST_GIT_URL ?= https://github.com/rust-lang/rust.git
82
RUST_TOOLS ?= cargo,clippy,rustdoc,rustfmt,rust-analyzer,analysis,src
9-
RUST_TARGETS ?= aarch64-apple-ios,aarch64-apple-darwin
3+
RUST_TARGETS ?= aarch64-apple-darwin,aarch64-apple-ios,arm64e-apple-darwin,arm64e-apple-ios
104
RUST_HOST ?= x86_64-apple-darwin
115
RUST_VERBOSE ?= 0
126
RUST_CHANNEL ?= dev
@@ -15,30 +9,20 @@ RUST_INSTALL_DIR ?= install
159
RUST_DIST_FORMATS ?= xz
1610
RUST_USE_LLD ?= false
1711

18-
# NOTE: use Makefile.local for customization
19-
-include Makefile.local
20-
2112
.PHONY: help
2213
help: ## Show this help
2314
@fgrep -h "## " $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/## //'
2415

16+
# Note: use Makefile.local for customization
17+
-include misc/make/offline.Makefile
18+
-include Makefile.local
19+
2520
## ▸▸▸ Download commands ◂◂◂
2621

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

31-
.PHONY: download-offline
32-
download-offline: SHELL:=/bin/bash
33-
download-offline: ## Download prebuilt Rust binaries
34-
mkdir -p ${RUST_PREBUILT_OUTPUT_DIR}/${RUST_PREBUILT_VERSION}
35-
@for RUST_CHANNEL in ${RUST_PREBUILT_CHANNELS}; do \
36-
for RUST_COMPONENT in ${RUST_PREBUILT_COMPONENTS}; do \
37-
RUST_FILENAME=${RUST_PREBUILT_VERSION}/$${RUST_COMPONENT}-$${RUST_CHANNEL}-${RUST_PREBUILT_TARGET}.tar.xz ; \
38-
curl --fail https://static.rust-lang.org/dist/$${RUST_FILENAME} --output ${RUST_PREBUILT_OUTPUT_DIR}/$${RUST_FILENAME} ; \
39-
done; \
40-
done;
41-
4226
###
4327
# Configure: https://github.com/rust-lang/rust/blob/master/src/bootstrap/configure.py
4428
###

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ $ make
1111
help: Show this help
1212
▸▸▸ Download commands ◂◂◂
1313
download: Download Rust sources
14-
download-offline: Download prebuilt Rust binaries
1514
▸▸▸ Configure commands ◂◂◂
1615
configure: Configure Rust
1716
configure-with-llvm: Configure Rust and LLVM
1817
▸▸▸ Target Info commands ◂◂◂
1918
show-target-info: Show target info
19+
▸▸▸ Offline commands ◂◂◂
20+
offline: Download prebuilt Rust binaries and cache them for offline use
2021
```
2122

2223
<!--

misc/make/offline.Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
RUST_PREBUILT_VERSION ?= $(shell curl --silent https://static.rust-lang.org/dist/channel-rust-beta.toml | grep '^date = "' | sed 's/date = "\(.*\)"/\1/')
2+
RUST_PREBUILT_COMPONENTS ?= rust-std rustc cargo rustfmt
3+
RUST_PREBUILT_CHANNELS ?= beta nightly
4+
RUST_PREBUILT_TARGET ?= x86_64-apple-darwin
5+
RUST_PREBUILT_OUTPUT_DIR ?= rust/build/cache
6+
7+
## ▸▸▸ Offline commands ◂◂◂
8+
9+
.PHONY: offline
10+
offline: SHELL:=/bin/bash
11+
offline: ## Download prebuilt Rust binaries and cache them for offline use
12+
mkdir -p ${RUST_PREBUILT_OUTPUT_DIR}/${RUST_PREBUILT_VERSION}
13+
@for RUST_CHANNEL in ${RUST_PREBUILT_CHANNELS}; do \
14+
for RUST_COMPONENT in ${RUST_PREBUILT_COMPONENTS}; do \
15+
RUST_FILENAME=${RUST_PREBUILT_VERSION}/$${RUST_COMPONENT}-$${RUST_CHANNEL}-${RUST_PREBUILT_TARGET}.tar.xz ; \
16+
INFO="\nFile Name: $${RUST_FILENAME}\nSize: %{size_download} bytes\nSpeed: %{speed_download} bytes/sec\nTime: %{time_total} seconds\n\n" ; \
17+
URL=https://static.rust-lang.org/dist/$${RUST_FILENAME} ; \
18+
OUTPUT=${RUST_PREBUILT_OUTPUT_DIR}/$${RUST_FILENAME} ; \
19+
curl --fail --progress-bar --write-out "$${INFO}" $${URL} --output $${OUTPUT} ; \
20+
done; \
21+
done;

0 commit comments

Comments
 (0)