|
16 | 16 | # under the License.
|
17 | 17 | #
|
18 | 18 |
|
| 19 | +BINDIR := node_modules/.bin |
| 20 | +TYPINGS := $(BINDIR)/typings |
| 21 | +TSC := $(BINDIR)/tsc |
| 22 | +TYPEDOC := $(BINDIR)/typedoc |
| 23 | + |
| 24 | +DOCURI := "https://github.com/hyperledger/fabric/tree/master/sdk/node/" |
| 25 | + |
| 26 | +SRC := $(shell find src -type f) |
| 27 | +CONFIG := $(shell ls *.json) |
| 28 | + |
19 | 29 | EXECUTABLES = npm
|
20 | 30 | K := $(foreach exec,$(EXECUTABLES),\
|
21 | 31 | $(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH: Check dependencies")))
|
22 | 32 |
|
23 |
| -all: hfc |
| 33 | +# npm tool->pkg mapping |
| 34 | +npm.pkg.typings := typings |
| 35 | +npm.pkg.tsc := typescript |
| 36 | +npm.pkg.typedoc := typedoc |
| 37 | + |
| 38 | +all: lib doc |
| 39 | + |
| 40 | +.PHONY: lib doc |
| 41 | +lib: lib/hfc.js |
| 42 | +doc: doc/index.html |
| 43 | + |
| 44 | +.SECONDARY: $(TYPINGS) $(TSC) $(TYPEDOC) |
| 45 | +$(BINDIR)/%: $(CONFIG) |
| 46 | + @echo "[INSTALL] $@" |
| 47 | + npm install $(npm.pkg.$(@F)) |
| 48 | + @touch $@ |
| 49 | + |
| 50 | +doc/index.html: $(TYPEDOC) $(SRC) $(CONFIG) typedoc-special.d.ts Makefile |
| 51 | + @echo "[BUILD] SDK documentation" |
| 52 | + @-rm -rf $(@D) |
| 53 | + @mkdir -p $(@D) |
| 54 | + $(TYPEDOC) -m amd \ |
| 55 | + --name 'Node.js Hyperledger Fabric SDK' \ |
| 56 | + --includeDeclarations \ |
| 57 | + --excludeExternals \ |
| 58 | + --excludeNotExported \ |
| 59 | + --out $(@D) \ |
| 60 | + src/hfc.ts typedoc-special.d.ts |
| 61 | + # Typedoc generates links to working GIT repo which is fixed |
| 62 | + # below to use an official release URI. |
| 63 | + find $(@D) -name '*.html' -exec sed -i 's!href="http.*sdk/node/!href="'$(DOCURI)'!' {} \; |
24 | 64 |
|
25 |
| -.PHONY: hfc |
26 |
| -hfc: |
27 |
| - mkdir -p ./lib/protos |
28 |
| - cp ../../protos/*.proto ./lib/protos |
29 |
| - cp ../../membersrvc/protos/*.proto ./lib/protos |
30 |
| - npm ls -g | grep 'typings' || sudo npm install -g typings |
31 |
| - npm ls -g | grep 'typescript' || sudo npm install -g typescript |
32 |
| - npm install && typings install |
33 |
| - tsc |
34 |
| - ./makedoc.sh |
| 65 | +lib/hfc.js: $(TYPINGS) $(TSC) $(SRC) $(CONFIG) Makefile |
| 66 | + @echo "[BUILD] SDK" |
| 67 | + @mkdir -p ./lib/protos |
| 68 | + @cp ../../protos/*.proto ./lib/protos |
| 69 | + @cp ../../membersrvc/protos/*.proto ./lib/protos |
| 70 | + npm install |
| 71 | + $(TYPINGS) install |
| 72 | + $(TSC) |
35 | 73 |
|
36 |
| -unit-tests: hfc |
| 74 | +unit-tests: lib |
| 75 | + @echo "[RUN] unit tests..." |
37 | 76 | @./bin/run-unit-tests.sh
|
38 | 77 |
|
39 | 78 | clean:
|
| 79 | + @echo "[CLEAN]" |
| 80 | + -rm -rf node_modules |
| 81 | + -rm -rf doc |
| 82 | + -find lib | grep -v "protos/google" | grep -v "hash.js" | xargs rm |
0 commit comments