Skip to content

Commit 0b9e3d2

Browse files
authored
Build system fixes for macos (#486) (#487)
On macos, GNU make eagerly avoids calling into the shell, so exposing node commands through $PATH doesn't work half of the time. Also, refactor build system a bit to have less repitition so that the build is easier to maintain. Or at least I think so.
1 parent 8cd6880 commit 0b9e3d2

File tree

10 files changed

+87
-135
lines changed

10 files changed

+87
-135
lines changed

common.mk

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
11
# This makefile is intended to be included by each package's makefile. The
22
# paths are relative to the package directory.
33

4-
ROOT := $(CURDIR)/..
4+
ROOT := $(dir $(lastword $(MAKEFILE_LIST)))
55
SOURCES := $(wildcard src/*)
66
VERSION := $(shell node -pe "require('./package.json').version")
7+
DOC_DESTINATION := $(subst @fluent, ../html, $(PACKAGE))
78

89
export SHELL := /bin/bash
9-
export PATH := $(CURDIR)/node_modules/.bin:$(ROOT)/node_modules/.bin:$(PATH)
10+
ESLINT ?= $(ROOT)node_modules/.bin/eslint
11+
TSC ?= $(ROOT)node_modules/.bin/tsc
12+
NYC ?= $(ROOT)node_modules/.bin/nyc
13+
MOCHA ?= $(ROOT)node_modules/.bin/mocha
14+
ROLLUP ?= $(ROOT)node_modules/.bin/rollup
15+
TYPEDOC ?= $(ROOT)node_modules/.bin/typedoc
16+
17+
ROLLUP_CMD = $(ROLLUP) $(CURDIR)/esm/index.js \
18+
--banner "/* $(PACKAGE)@$(VERSION) */" \
19+
--amd.id $(PACKAGE) \
20+
--name $(GLOBAL) \
21+
--output.format umd \
22+
--output.file \
23+
$(NULL)
24+
25+
TYPEDOC_CMD = $(TYPEDOC) src \
26+
--out $(DOC_DESTINATION) \
27+
--mode file \
28+
--excludeNotExported \
29+
--excludePrivate \
30+
--logger none \
31+
--hideGenerator \
32+
$(NULL)
33+
34+
MOCHA_CMD =@$(NYC) --reporter=text --reporter=html $(MOCHA) \
35+
--recursive --ui tdd \
36+
--require esm \
37+
$(MOCHA_EXTRA_ARGS) \
38+
test/**/*_test.js \
39+
$(NULL)
1040

1141
# Common maintenance tasks.
1242
.PHONY: clean lint test build html

fluent-bundle/makefile

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,37 @@ GLOBAL := FluentBundle
44
include ../common.mk
55

66
lint:
7-
@eslint --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts
8-
@eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/
7+
@$(ESLINT) --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts
8+
@$(ESLINT) --config $(ROOT)/eslint_test.json --max-warnings 0 test/
99
@echo -e " $(OK) lint"
1010

1111
.PHONY: compile
1212
compile: esm/.compiled
1313

1414
esm/.compiled: $(SOURCES)
15-
@tsc
15+
@$(TSC)
1616
@touch $@
1717
@echo -e " $(OK) esm/ compiled"
1818

1919
.PHONY: test
2020
test: esm/.compiled
21-
@nyc --reporter=text --reporter=html mocha \
22-
--recursive --ui tdd \
23-
--require esm \
24-
test/**/*_test.js
21+
@$(MOCHA_CMD)
2522

2623
.PHONY: build
2724
build: index.js
2825

2926
index.js: esm/.compiled
30-
@rollup $(CURDIR)/esm/index.js \
31-
--banner "/* $(PACKAGE)@$(VERSION) */" \
32-
--amd.id $(PACKAGE) \
33-
--name $(GLOBAL) \
34-
--output.format umd \
35-
--output.file $@
27+
@$(ROLLUP_CMD) $@
3628
@echo -e " $(OK) $@ built"
3729

3830
html:
39-
@typedoc src \
40-
--out ../html/bundle \
41-
--mode file \
42-
--excludeNotExported \
43-
--excludePrivate \
44-
--logger none \
45-
--hideGenerator
31+
@$(TYPEDOC_CMD)
4632
@echo -e " $(OK) html built"
4733

4834
clean:
4935
@rm -f esm/*.js esm/*.d.ts esm/.compiled
5036
@rm -f index.js
37+
@rm -rf $(DOC_DESTINATION)
5138
@rm -rf .nyc_output coverage
5239
@echo -e " $(OK) clean"
5340

fluent-dedent/makefile

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,31 @@ GLOBAL := FluentDedent
44
include ../common.mk
55

66
lint:
7-
@eslint --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts
8-
@eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/
7+
@$(ESLINT) --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts
8+
@$(ESLINT) --config $(ROOT)/eslint_test.json --max-warnings 0 test/
99
@echo -e " $(OK) lint"
1010

1111
.PHONY: compile
1212
compile: esm/.compiled
1313

1414
esm/.compiled: $(SOURCES)
15-
@tsc
15+
@$(TSC)
1616
@touch $@
1717
@echo -e " $(OK) esm/ compiled"
1818

1919
.PHONY: test
2020
test: esm/.compiled
21-
@nyc --reporter=text --reporter=html mocha \
22-
--recursive --ui tdd \
23-
--require esm \
24-
test/**/*_test.js
21+
@$(MOCHA_CMD)
2522

2623
.PHONY: build
2724
build: index.js
2825

2926
index.js: esm/.compiled
30-
@rollup $(CURDIR)/esm/index.js \
31-
--banner "/* $(PACKAGE)@$(VERSION) */" \
32-
--amd.id $(PACKAGE) \
33-
--name $(GLOBAL) \
34-
--output.format umd \
35-
--output.file $@
27+
@$(ROLLUP_CMD) $@
3628
@echo -e " $(OK) $@ built"
3729

3830
html:
39-
@typedoc src \
40-
--out ../html/dedent \
41-
--mode file \
42-
--excludeNotExported \
43-
--excludePrivate \
44-
--logger none \
45-
--hideGenerator
31+
@$(TYPEDOC_CMD)
4632
@echo -e " $(OK) html built"
4733

4834
clean:

fluent-dom/makefile

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,28 @@ DEPS := cached-iterable:CachedIterable
55
include ../common.mk
66

77
lint:
8-
@eslint --config $(ROOT)/eslint_js.json --max-warnings 0 src/
9-
@eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/
8+
@$(ESLINT) --config $(ROOT)/eslint_js.json --max-warnings 0 src/
9+
@$(ESLINT) --config $(ROOT)/eslint_test.json --max-warnings 0 test/
1010
@echo -e " $(OK) lint"
1111

1212
.PHONY: compile
1313
compile: esm/.compiled
1414

1515
esm/.compiled: $(SOURCES)
16-
@tsc
16+
@$(TSC)
1717
@touch $@
1818
@echo -e " $(OK) esm/ compiled"
1919

2020
.PHONY: test
21+
test: MOCHA_EXTRA_ARGS=--require ./test/index
2122
test: esm/.compiled
22-
@nyc --reporter=text --reporter=html mocha \
23-
--recursive --ui tdd \
24-
--require esm \
25-
--require ./test/index \
26-
test/**/*_test.js
23+
@$(MOCHA_CMD)
2724

2825
.PHONY: build
2926
build: index.js
3027

3128
index.js: esm/.compiled
32-
@rollup $(CURDIR)/esm/index.js \
29+
@$(ROLLUP) $(CURDIR)/esm/index.js \
3330
--banner "/* $(PACKAGE)@$(VERSION) */" \
3431
--amd.id $(PACKAGE) \
3532
--name $(GLOBAL) \
@@ -39,17 +36,12 @@ index.js: esm/.compiled
3936
@echo -e " $(OK) $@ built"
4037

4138
html:
42-
@typedoc src \
43-
--out ../html/dom \
44-
--mode file \
45-
--excludeNotExported \
46-
--excludePrivate \
47-
--logger none \
48-
--hideGenerator
39+
@$(TYPEDOC_CMD)
4940
@echo -e " $(OK) html built"
5041

5142
clean:
5243
@rm -f esm/*.js esm/*.d.ts esm/.compiled
5344
@rm -f index.js
45+
@rm -rf $(DOC_DESTINATION)
5446
@rm -rf .nyc_output coverage
5547
@echo -e " $(OK) clean"

fluent-gecko/makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ version = $(1)@$(shell node -e "\
77
console.log(require('../$(1)/package.json').version)")
88

99
lint:
10-
@eslint --config $(ROOT)/eslint_js.json --max-warnings 0 src/
10+
@$(ESLINT) --config $(ROOT)/eslint_js.json --max-warnings 0 src/
1111
@echo -e " $(OK) lint"
1212

1313
test: ;
@@ -17,7 +17,7 @@ build: FluentSyntax.jsm fluent-react.js
1717

1818
FluentSyntax.jsm: $(SOURCES)
1919
$(MAKE) -sC ../fluent-syntax compile
20-
@rollup $(CURDIR)/src/fluent-syntax.js \
20+
@$(ROLLUP) $(CURDIR)/src/fluent-syntax.js \
2121
--config ./xpcom_config.js \
2222
--no-treeshake \
2323
--no-freeze \
@@ -27,7 +27,7 @@ FluentSyntax.jsm: $(SOURCES)
2727

2828
fluent-react.js: $(SOURCES)
2929
$(MAKE) -sC ../fluent-react compile
30-
@rollup $(CURDIR)/src/fluent-react.js \
30+
@$(ROLLUP) $(CURDIR)/src/fluent-react.js \
3131
--config ./vendor_config.js \
3232
--output.intro "/* $(call version,fluent-react) */" \
3333
--output.file ./dist/$@

fluent-langneg/makefile

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,36 @@ GLOBAL := FluentLangNeg
44
include ../common.mk
55

66
lint:
7-
@eslint --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts
8-
@eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/
7+
@$(ESLINT) --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts
8+
@$(ESLINT) --config $(ROOT)/eslint_test.json --max-warnings 0 test/
99
@echo -e " $(OK) lint"
1010

1111
.PHONY: compile
1212
compile: esm/.compiled
1313

1414
esm/.compiled: $(SOURCES)
15-
@tsc
15+
@$(TSC)
1616
@touch $@
1717
@echo -e " $(OK) esm/ compiled"
1818

1919
.PHONY: test
2020
test: esm/.compiled
21-
@nyc --reporter=text --reporter=html mocha \
22-
--recursive --ui tdd \
23-
--require esm \
24-
test/**/*_test.js
21+
@$(MOCHA_CMD)
2522

2623
.PHONY: build
2724
build: index.js
2825

2926
index.js: $(SOURCES)
30-
@rollup $(CURDIR)/esm/index.js \
31-
--banner "/* $(PACKAGE)@$(VERSION) */" \
32-
--amd.id $(PACKAGE) \
33-
--name $(GLOBAL) \
34-
--output.format umd \
35-
--output.file $@
27+
@$(ROLLUP_CMD) $@
3628
@echo -e " $(OK) $@ built"
3729

3830
html:
39-
@typedoc src \
40-
--out ../html/langneg \
41-
--mode file \
42-
--excludeNotExported \
43-
--excludePrivate \
44-
--logger none \
45-
--hideGenerator
31+
@$(TYPEDOC_CMD)
4632
@echo -e " $(OK) html built"
4733

4834
clean:
4935
@rm -f esm/*.js esm/*.d.ts esm/.compiled
5036
@rm -f index.js
37+
@rm -rf $(DOC_DESTINATION)
5138
@rm -rf .nyc_output coverage
5239
@echo -e " $(OK) clean"

fluent-react/makefile

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
PACKAGE := @fluent/react
22
GLOBAL := FluentReact
3+
JEST ?= node_modules/.bin/jest
34

45
include ../common.mk
56

67
lint:
7-
@eslint --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts
8-
@eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/
8+
@$(ESLINT) --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts
9+
@$(ESLINT) --config $(ROOT)/eslint_test.json --max-warnings 0 test/
910
@echo -e " $(OK) lint"
1011

1112
.PHONY: compile
1213
compile: esm/.compiled
1314

1415
esm/.compiled: $(SOURCES)
15-
@tsc
16+
@$(TSC)
1617
@touch $@
1718
@echo -e " $(OK) esm/ compiled"
1819

1920
.PHONY: test
2021
test: esm/.compiled
21-
@jest --collect-coverage
22+
@$(JEST) --collect-coverage
2223

2324
.PHONY: build
2425
build: index.js
2526

2627
index.js: esm/.compiled
27-
@rollup $(CURDIR)/esm/index.js \
28+
@$(ROLLUP) $(CURDIR)/esm/index.js \
2829
--banner "/* $(PACKAGE)@$(VERSION) */" \
2930
--amd.id $(PACKAGE) \
3031
--name $(GLOBAL) \
@@ -34,17 +35,12 @@ index.js: esm/.compiled
3435
@echo -e " $(OK) $@ built"
3536

3637
html:
37-
@typedoc src \
38-
--out ../html/react \
39-
--mode file \
40-
--excludeNotExported \
41-
--excludePrivate \
42-
--logger none \
43-
--hideGenerator
38+
@$(TYPEDOC_CMD)
4439
@echo -e " $(OK) html built"
4540

4641
clean:
4742
@rm -f esm/*.js esm/*.d.ts esm/.compiled
4843
@rm -f index.js
44+
@rm -rf $(DOC_DESTINATION)
4945
@rm -rf .nyc_output coverage
5046
@echo -e " $(OK) clean"

0 commit comments

Comments
 (0)