Skip to content

Commit c750637

Browse files
committed
Add more build system doc.
1 parent bd4c2f6 commit c750637

File tree

1 file changed

+107
-7
lines changed

1 file changed

+107
-7
lines changed

src/content/docs/articles/the-rubinius-build-system.mdoc

Lines changed: 107 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ implementation. A couple folks created fun languages that target Rubinius
2626
([Atomy](https://github.com/vito/atomy) and
2727
[Fancy](https://github.com/bakkdoor/fancy) are notable).
2828

29+
## build2
30+
2931
In the past ten-ish years, a lot has happened in programming languages and
3032
software. For one, there's a major new build system for C/C++:
3133
[build2](https://www.build2.org)
@@ -43,38 +45,108 @@ system just must do it its own way, it can remix easily and safely.
4345
The rest of this article explains in detail how the Rubinius build system
4446
works.
4547

48+
## Scale & Complexity
49+
50+
"One of these is not like the others" is the source of a lot of pain and
51+
suffering in many software systems because even small differences can add
52+
complexity. Where that difference is managed helps deal with that complexity.
53+
54+
Another challenge in systems is their scale. Since software is often
55+
intangible, it can be hard to get a sense of the scale of it, other than
56+
looking at all the source files, but even that can't directly show the
57+
functional complexity of a piece of software.
58+
4659
Scale:
4760

4861
1. Large galaxy: Linux;
4962
1. Small galaxy: LLVM;
5063
1. Solar system: Rubinius;
5164
1. Jupiter-sized planet: rbx compiler;
5265
1. Earth-sized planet: Ruby core library;
53-
1. Large mountain on earth: A library like OpenFHE;
66+
1. Large mountain on earth: A library like oniguruma;
5467
1. Big hill: A library like libasio;
5568
1. A large rock: Python PEG parser;
5669
1. A smaller rock: CLI11 command line libray.
5770

58-
Anything the size of a rock should be a separately-buildable package, and anything larger than a rock should only be a composition of such packages.
71+
Based on this, we can say that anything the size of a large mountain and
72+
smaller should be in its own separately-buildable package, and anything larger
73+
than a rock should only be a composition of such packages.
5974

60-
Every biological system is a collection of well-bounded components, most of them microscopic. Only humans, in their infinite "wisdom" conjure something like Bazel.
75+
Every biological system is a collection of well-bounded components, most of
76+
them microscopic. Only humans, in their infinite "wisdom" conjure something
77+
like Bazel.
6178

62-
Why would anyone want to install Java to build a C/C++ library?
79+
Putting planets, solar systems, and galaxies into one package (or one
80+
monolithic build system), is just begging for a lot of unnecessary complexity
81+
because the number of "one of these is not like the others" grows and tends to
82+
get mixed-in places that make changes harder and harder.
83+
84+
One reason for this is because without unbreakable boundaries (e.g. that code
85+
requires a separate `git clone`) "DRY" up the build script or "parameterize" a
86+
subroutine is often irresistible.
6387

6488
## Setting Boundaries
6589

66-
Some reasons to put a component in its own repository:
90+
Scale is one consideration for when to impose some boundaries. Some other
91+
reasons to put a component in its own repository:
6792

6893
* It's in a different programming language;
6994
* It's not our code;
7095
* It's only used on some systems;
7196
* It's one of several viable options;
7297
* It has particular testing or security concerns;
7398

74-
**( This document is a draft work-in-progress. )**
99+
## Minimum Build Requirements
100+
101+
The intended requirements for building a Rubinius component are:
102+
103+
1. make
104+
2. clang/clang++
105+
3. build2
106+
107+
### Makefile
108+
109+
```make
110+
PROJ = rbx
111+
112+
# Allow override (e.g., `make VERSION=1.2.3`)
113+
VERSION ?= $(shell (git describe --tags 2>/dev/null || echo "develop") | sed 's/^v//')
114+
REVISION ?= $(shell git rev-parse --short HEAD)
115+
116+
.PHONY: help setup config build install release test clean all
117+
118+
all: setup config build test
119+
120+
##@ Dependencies
121+
setup: ## Clone all components
122+
@git submodule update --init --recursive
123+
@./.build2/scripts/setup-build2.sh $(PROJ)
124+
125+
config: ## Configure
126+
@./.build2/scripts/config-build2.sh $(PROJ)
127+
128+
##@ Development
129+
build: ## Build all components
130+
@./.build2/scripts/build-build2.sh $(PROJ)
131+
132+
##@ Testing
133+
test: ## Run the tests
134+
@./.build2/scripts/test-build2.sh $(PROJ)
135+
136+
##@ Maintenance
137+
clean: ## Remove all build artifacts
138+
@./.build2/scripts/clean-build2.sh $(PROJ)
139+
140+
help: ## Display this help
141+
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[.a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
142+
```
143+
144+
You may notice something a bit different in tis Makefile: the `help` target.
145+
This is a neat way to add easy guidance to newcomers and is often helpful even
146+
for experienced contributors.
75147

76148
```
77-
make help
149+
$ make help
78150
Usage:
79151
make <target>
80152

@@ -92,3 +164,31 @@ Maintenance
92164
clean Remove all build artifacts
93165
help Display this help
94166
```
167+
168+
### The Build Steps
169+
170+
The steps to build a component are standardized as much as possible across all
171+
components.
172+
173+
#### setup
174+
175+
The `setup` target ensures that all source code and input files are present. If
176+
some of the files need to be generated, this step of the build process should
177+
handle that.
178+
179+
#### config
180+
181+
The `config` target prepares the source code for the build process.
182+
183+
#### build
184+
185+
The `build` target builds the _default artifact_. For a library, this would be
186+
the library itself. For an application, this would be the executable. For
187+
something like Ruby code, it may be the source files itself, or for a system
188+
like Rubinius, it could be bytecode files or even an executable.
189+
190+
#### test
191+
192+
The `test` target checks the integrity of the default artifact. For a library,
193+
this may be a sample application that exercises the library's API. For an
194+
executable, this may be automated tests that mimic a user's interaction.

0 commit comments

Comments
 (0)