Skip to content

Commit

Permalink
Update build script to include ko.version (selectively merged from mt…
Browse files Browse the repository at this point in the history
…scout6's "versioning" branch - thanks Matt!)
  • Loading branch information
SteveSanderson committed Jan 10, 2012
1 parent f3158dd commit c9abfe6
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.suo
*.swp
*.csproj.user
bin
obj
Expand Down
14 changes: 12 additions & 2 deletions build/build-linux
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
OutDebugFile='output/knockout-latest.debug.js'
OutMinFile='output/knockout-latest.js'

Version=`cat fragments/version.txt`
VersionHeaderPath='fragments/version-header.js'
VersionJsFile='../src/version.js'
sed "s/##VERSION##/$Version/" <$VersionHeaderPath > $VersionHeaderPath.temp
sed "s/Working-Debug/$Version/" <$VersionJsFile > $VersionJsFile.temp

# Combine the source files
SourceFiles=`grep js < fragments/source-references.js | # Find JS references
sed "s/[ \',]//g" | # Strip off JSON fluff (whitespace, commas, quotes)
sed -e 's/.*/..\/&/' | # Fix the paths by prefixing with ../
sed "s/version\.js/version\.js\.temp/" | # Use a temporary version with correct version number
tr '\n' ' '` # Combine into single line
cat fragments/amd-pre.js > $OutDebugFile.temp
cat $SourceFiles >> $OutDebugFile.temp
Expand All @@ -16,14 +23,17 @@ cat fragments/amd-post.js >> $OutDebugFile.temp
curl -d output_info=compiled_code -d output_format=text -d compilation_level=ADVANCED_OPTIMIZATIONS --data-urlencode js_code@$OutDebugFile.temp "http://closure-compiler.appspot.com/compile" > $OutMinFile.temp

# Finalise each file by prefixing with version header and surrounding in function closure
cp fragments/version-header.js $OutDebugFile
cp $VersionHeaderPath.temp $OutDebugFile
echo "(function(window,document,navigator,undefined){" >> $OutDebugFile
cat $OutDebugFile.temp >> $OutDebugFile
echo "})(window,document,navigator);" >> $OutDebugFile
rm $OutDebugFile.temp

cp fragments/version-header.js $OutMinFile
cp $VersionHeaderPath.temp $OutMinFile
echo "(function(window,document,navigator,undefined){" >> $OutMinFile
cat $OutMinFile.temp >> $OutMinFile
echo "})(window,document,navigator);" >> $OutMinFile
rm $OutMinFile.temp

rm $VersionHeaderPath.temp
rm $VersionJsFile.temp
17 changes: 15 additions & 2 deletions build/build-windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ set OutMinFile=output\knockout-latest.js
set AllFiles=
for /f "eol=] skip=1 delims=' " %%i in (fragments\source-references.js) do set Filename=%%i& call :Concatenate

set /p Version= <fragments\version.txt
set VersionHeaderPath=fragments\version-header.js
set VersionJsFile=..\src\version.js
tools\sed "s/##VERSION##/%Version%/" <%VersionHeaderPath% > %VersionHeaderPath%.temp
tools\sed "s/Working-Debug/%Version%/" <%VersionJsFile% > %VersionJsFile%.temp

goto :Combine
:Concatenate
if /i "%Filename%"=="src/version.js" (
set Filename="src/version.js.temp"
)

if /i "%AllFiles%"=="" (
set AllFiles=..\%Filename:/=\%
) else (
Expand All @@ -22,14 +32,17 @@ type fragments\amd-post.js >> %OutDebugFile%.temp
tools\curl -d output_info=compiled_code -d output_format=text -d compilation_level=ADVANCED_OPTIMIZATIONS --data-urlencode js_code@%OutDebugFile%.temp "http://closure-compiler.appspot.com/compile" > %OutMinFile%.temp

@rem Finalise each file by prefixing with version header and surrounding in function closure
copy /y fragments\version-header.js %OutDebugFile%
copy /y fragments\version-header.js.temp %OutDebugFile%
echo (function(window,document,navigator,undefined){ >> %OutDebugFile%
type %OutDebugFile%.temp >> %OutDebugFile%
echo })(window,document,navigator); >> %OutDebugFile%
del %OutDebugFile%.temp

copy /y fragments\version-header.js %OutMinFile%
copy /y fragments\version-header.js.temp %OutMinFile%
echo (function(window,document,navigator,undefined){ >> %OutMinFile%
type %OutMinFile%.temp >> %OutMinFile%
echo })(window,document,navigator); >> %OutMinFile%
del %OutMinFile%.temp

del %VersionHeaderPath%.temp
del %VersionJsFile%.temp
9 changes: 5 additions & 4 deletions build/fragments/source-references.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
knockoutDebugCallback([
'src/namespace.js',
'src/google-closure-compiler-utils.js',
'src/version.js',
'src/utils.js',
'src/utils.domData.js',
'src/utils.domNodeDisposal.js',
'src/utils.domManipulation.js',
'src/memoization.js',
'src/memoization.js',
'src/subscribables/extenders.js',
'src/subscribables/subscribable.js',
'src/subscribables/dependencyDetection.js',
Expand All @@ -22,9 +23,9 @@ knockoutDebugCallback([
'src/templating/templateEngine.js',
'src/templating/templateRewriting.js',
'src/templating/templateSources.js',
'src/templating/templating.js',
'src/templating/templating.js',
'src/binding/editDetection/compareArrays.js',
'src/binding/editDetection/arrayToDomNodeChildren.js',
'src/templating/native/nativeTemplateEngine.js',
'src/templating/jquery.tmpl/jqueryTmplTemplateEngine.js'
]);
'src/templating/jquery.tmpl/jqueryTmplTemplateEngine.js'
]);
2 changes: 1 addition & 1 deletion build/fragments/version-header.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Knockout JavaScript library v2.1.0pre
// Knockout JavaScript library v##VERSION##
// (c) Steven Sanderson - http://knockoutjs.com/
// License: MIT (http://www.opensource.org/licenses/mit-license.php)

1 change: 1 addition & 0 deletions build/fragments/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.1.0pre
3 changes: 3 additions & 0 deletions src/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ko.version = "Working-Debug";

ko.exportSymbol('version', ko.version);

0 comments on commit c9abfe6

Please sign in to comment.