public
Created

Makefile for TypeScript on OSX, Linux, etc

  • Download Gist
Makefile
Makefile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
TYPESCRIPT_HOST=node
BASE= ./
 
BIN=$(BASE)bin
BUILT=$(BASE)built
BUILT_LOCAL=$(BUILT)/local
BUILT_LOCALTEST=$(BUILT)/localtest
 
HOST=$(TYPESCRIPT_HOST)
 
#compiler source location
CSRC=$(BASE)src/compiler
 
#compiler services source location
SSRC=$(BASE)src/services
 
#library source location
LSRC=$(BASE)typings
 
#test source location
TSRC=$(BASE)test
 
# harness source location
HSRC=$(BASE)src/harness
 
STRC_LOCAL=$(HOST) $(BUILT_LOCAL)/tsc.js -cflowu
STRC_LKG=$(HOST) $(BIN)/tsc.js -cflowu
 
COMPILER_SOURCES_BASE= \
$(CSRC)/diagnostics.ts \
$(CSRC)/flags.ts \
$(CSRC)/nodeTypes.ts \
$(CSRC)/hashTable.ts \
$(CSRC)/printContext.ts \
$(CSRC)/scopeWalk.ts \
$(CSRC)/typeCollection.ts \
$(CSRC)/scopeAssignment.ts \
$(CSRC)/binder.ts \
$(CSRC)/tokens.ts \
$(CSRC)/ast.ts \
$(CSRC)/astWalker.ts \
$(CSRC)/astPath.ts \
$(CSRC)/astLogger.ts \
$(CSRC)/scanner.ts \
$(CSRC)/parser.ts \
$(CSRC)/symbolScope.ts \
$(CSRC)/types.ts \
$(CSRC)/signatures.ts \
$(CSRC)/symbols.ts \
$(CSRC)/errorReporter.ts \
$(CSRC)/typeFlow.ts \
$(CSRC)/typeChecker.ts \
$(CSRC)/base64.ts \
$(CSRC)/sourceMapping.ts \
$(CSRC)/emitter.ts \
$(CSRC)/precompile.ts \
$(CSRC)/incrementalParser.ts \
$(CSRC)/pathUtils.ts \
$(CSRC)/referenceResolution.ts \
$(CSRC)/typescript.ts
 
COMPILER_SOURCES=$(COMPILER_SOURCES_BASE)
FRONTEND_SOURCES=$(COMPILER_SOURCES) $(CSRC)/io.ts $(CSRC)/optionsParser.ts $(CSRC)/tsc.ts
 
SERVICES_SOURCES_BASE= \
$(SSRC)/es5compat.ts \
$(SSRC)/formatting/formatting.ts \
$(SSRC)/formatting/interop.ts \
$(SSRC)/formatting/formattingContext.ts \
$(SSRC)/formatting/formattingManager.ts \
$(SSRC)/formatting/formattingRequestKind.ts \
$(SSRC)/formatting/formattingTask.ts \
$(SSRC)/formatting/iformatter.ts \
$(SSRC)/formatting/ilineIndentationResolver.ts \
$(SSRC)/formatting/indentationBag.ts \
$(SSRC)/formatting/indentationEdgeFinder.ts \
$(SSRC)/formatting/indentationEditInfo.ts \
$(SSRC)/formatting/indentationInfo.ts \
$(SSRC)/formatting/indenter.ts \
$(SSRC)/formatting/matchingBlockFinderTask.ts \
$(SSRC)/formatting/parseNode.ts \
$(SSRC)/formatting/parseNodeExtensions.ts \
$(SSRC)/formatting/parseTree.ts \
$(SSRC)/formatting/rule.ts \
$(SSRC)/formatting/ruleAction.ts \
$(SSRC)/formatting/ruleDescriptor.ts \
$(SSRC)/formatting/ruleFlag.ts \
$(SSRC)/formatting/ruleOperation.ts \
$(SSRC)/formatting/ruleOperationContext.ts \
$(SSRC)/formatting/rules.ts \
$(SSRC)/formatting/rulesMap.ts \
$(SSRC)/formatting/rulesProvider.ts \
$(SSRC)/formatting/smartIndentManager.ts \
$(SSRC)/formatting/smartIndentTask.ts \
$(SSRC)/formatting/statementFinderTask.ts \
$(SSRC)/formatting/textEditInfo.ts \
$(SSRC)/formatting/tokenRange.ts \
$(SSRC)/formatting/tokenSpan.ts \
$(SSRC)/classifier.ts \
$(SSRC)/coreServices.ts \
$(SSRC)/scriptSyntaxAST.ts \
$(SSRC)/compilerState.ts \
$(SSRC)/braceMatchingManager.ts \
$(SSRC)/symbolSet.ts \
$(SSRC)/symbolTree.ts \
$(SSRC)/overridesCollector.ts \
$(SSRC)/languageService.ts \
$(SSRC)/shims.ts \
$(SSRC)/typescriptServices.ts
 
SERVICES_SOURCES= \
$(COMPILER_SOURCES_BASE) \
$(SERVICES_SOURCES_BASE)
 
prebuild-local:
if [ ! -e $(BUILT) ] ; then mkdir $(BUILT) ; fi
if [ ! -e $(BUILT_LOCAL) ] ; then mkdir $(BUILT_LOCAL) ; fi
if [ ! -e $(BUILT_LOCALTEST) ] ; then mkdir $(BUILT_LOCALTEST) ; fi
cp -f $(LSRC)/lib.d.ts $(BUILT_LOCAL)/lib.d.ts
cp -f $(LSRC)/jquery.d.ts $(BUILT_LOCAL)/jquery.d.ts
cp -f $(LSRC)/winjs.d.ts $(BUILT_LOCAL)/winjs.d.ts
cp -f $(LSRC)/winrt.d.ts $(BUILT_LOCAL)/winrt.d.ts
 
$(BUILT_LOCAL)/typescript.js: $(COMPILER_SOURCES)
$(STRC_LKG) $(COMPILER_SOURCES) -out $@
cat CopyrightNotice.txt $@ > $(BUILT_LOCAL)/temp.js
cp $(BUILT_LOCAL)/temp.js $@
rm $(BUILT_LOCAL)/temp.js
 
$(BUILT_LOCAL)/tsc.js: $(FRONTEND_SOURCES)
$(STRC_LKG) $(FRONTEND_SOURCES) -out $@
cat CopyrightNotice.txt $@ > $(BUILT_LOCAL)/temp.js
cp $(BUILT_LOCAL)/temp.js $@
rm $(BUILT_LOCAL)/temp.js
 
$(BUILT_LOCAL)/typescriptServices.js: $(SERVICES_SOURCES)
$(STRC_LKG) $(SERVICES_SOURCES) -out $@
cat CopyrightNotice.txt ThirdPartyNoticeText.txt $@ > $(BUILT_LOCAL)/temp.js
cp $(BUILT_LOCAL)/temp.js $@
rm $(BUILT_LOCAL)/temp.js
 
local: prebuild-local $(BUILT_LOCAL)/typescript.js $(BUILT_LOCAL)/tsc.js $(BUILT_LOCAL)/typescriptServices.js
 
compiler: local
 
COMPILER_TESTS=--compiler
LS_TESTS=--ls
SERVICES_TESTS=--services
HARNESS_TESTS=--harness
 
unit-tests-dependencies: $(FRONTEND_SOURCES) $(SERVICES_SOURCES) $(HSRC)/harness.ts $(HSRC)/diff.ts $(HSRC)/exec.ts $(HSRC)/baselining.ts $(HSRC)/dumpAST-baselining.ts $(HSRC)/external/json2.ts $(HSRC)/runner.ts
 
# conditionally build unit test progrmams
$(BUILT_LOCALTEST)/run.js: unit-tests-dependencies
$(STRC_LOCAL) -noresolve $(SERVICES_SOURCES) $(CSRC)/io.ts $(HSRC)/exec.ts $(HSRC)/diff.ts $(HSRC)/harness.ts $(HSRC)/external/json2.ts $(HSRC)/baselining.ts $(HSRC)/dumpAST-baselining.ts -out $(BUILT_LOCALTEST)/harness.js
$(STRC_LOCAL) -noresolve $(SERVICES_SOURCES) $(CSRC)/io.ts $(HSRC)/exec.ts $(HSRC)/diff.ts $(HSRC)/harness.ts $(HSRC)/external/json2.ts $(HSRC)/generate.ts -out $(BUILT_LOCALTEST)/generate.js
$(STRC_LOCAL) -noresolve -target es5 $(SERVICES_SOURCES) $(CSRC)/io.ts $(CSRC)/optionsParser.ts $(HSRC)/exec.ts $(HSRC)/diff.ts $(HSRC)/harness.ts $(HSRC)/baselining.ts $(HSRC)/dumpAST-baselining.ts $(HSRC)/external/json2.ts $(HSRC)/runner.ts -out $(BUILT_LOCALTEST)/run.js
cp -f $(LSRC)/lib.d.ts $(BUILT_LOCALTEST)
 
# build unit test programs
unit-tests: $(BUILT_LOCALTEST)/run.js
 
tests: local unit-tests
 
runtests: tests
$(HOST) $(BUILT_LOCALTEST)/run.js $(tests)
 
runtests-compiler: tests
$(HOST) $(BUILT_LOCALTEST)/run.js $(COMPILER_TESTS)
 
runtests-ls: tests
$(HOST) $(BUILT_LOCALTEST)/run.js $(LS_TESTS)
 
runtests-services: tests
$(HOST) $(BUILT_LOCALTEST)/run.js $(SERVICES_TESTS)
 
runtests-harness: tests
$(HOST) $(BUILT_LOCALTEST)/run.js $(HARNESS_TESTS)
 
world: local tests
 
# create a new lkg
install-local: clean local
cp -f $(BUILT_LOCAL)/lib.d.ts $(BIN)
cp -f $(BUILT_LOCAL)/jquery.d.ts $(BIN)
cp -f $(BUILT_LOCAL)/winjs.d.ts $(BIN)
cp -f $(BUILT_LOCAL)/winrt.d.ts $(BIN)
cp -f $(BUILT_LOCAL)/typescript.js $(BIN)
cp -f $(BUILT_LOCAL)/tsc.js $(BIN)
cp -f $(BUILT_LOCAL)/typescriptServices.js $(BIN)
 
install: install-local
 
clean-local:
if [ -e $(BUILT_LOCAL) ] ; then rm -rf $(BUILT_LOCAL) ; fi
if [ -e $(BUILT_LOCALTEST) ] ; then rm -rf $(BUILT_LOCALTEST) ; fi
 
clean: clean-local
if [ -e $(BUILT) ] ; then rm -rf $(BUILT) ; fi
 
baseline-accept:
rsync -av --delete tests/baselines/local/ tests/baselines/reference

Tested on OSX and cygwin. "make runtests" will be failed due to backslash path issue.
http://typescript.codeplex.com/workitem/17

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.