Permalink
Fetching contributors…
Cannot retrieve contributors at this time
217 lines (176 sloc) 8.63 KB
<?xml version="1.0" encoding="UTF-8"?>
<!--
ANT-based build script for EnlighterJS
@author Andi Dittrich <opensource _AT andidittrich _D_O_T d-e>
@version 1.9
@license The MIT License (X11)
!-->
<project name="EnlighterJS" default="build" basedir=".">
<!-- AN-contrib !-->
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<!-- Target Properties ! -->
<property name="build.dir" value="Build/" />
<property name="tmp.dir" value=".tmp/" />
<property name="www.dir" value="PublicHtml/" />
<property name="example.dir" value="Examples/" />
<property name="build.var.version" value="2.10.1" />
<!-- Themes to include !-->
<property name="include.themes" value="Enlighter Godzilla Beyond Classic MooTwo Eclipse Droide Minimal Atomic Rowhammer Git Mocha MooTools Panic Tutti Twilight" />
<!-- Languages to include !-->
<property name="include.languages" value="Assembly AvrAssembly Css Cpp CSharp Diff Ini Java Javascript Json Lua Matlab Markdown Nsis Php Python Cython RAW Ruby Rust Shell Squirrel Sql Vhdl Xml" />
<!-- Sourcefiles to include !-->
<property name="include.JsBaseSources" value="EnlighterJS TextFilter Dom/MooTools/Dom Dom/MooTools/Element SpecialLineHighlighter LanguageManager Renderer/InlineRenderer Renderer/BlockRenderer Tokenizer/Standard Tokenizer/Xml UI/CodeWindow UI/Toolbar" />
<!-- Additional Features to include !-->
<property name="include.JsFeatures" value="Native/Element.EnlighterJS Util/Helper UI/TabPane Util/Metainit Util/Init" />
<!-- set date vars !-->
<tstamp/>
<!-- CP Notice !-->
<property name="cpnotice" value="/*! EnlighterJS Syntax Highlighter ${build.var.version} | MIT License (X11) | http://enlighterjs.org/ | ${TODAY} */"></property>
<!-- convert source lists to file lists !-->
<propertyregex property="source.css" input="Base ${include.themes}" regexp="(\w+)\b" replace="Source/Themes/\1.css" global="true" />
<propertyregex property="source.languages.js" input="Generic ${include.languages}" regexp="([\w/]+)\b" replace="Source/Language/\1.js" global="true" />
<propertyregex property="source.core.js" input="${include.JsBaseSources} ${include.JsFeatures}" regexp="([\w/\.]+)\b" replace="Source/\1.js" global="true" />
<!-- Generate Build -->
<target name="build">
<!-- Cleanup Build Dir -->
<delete dir="${build.dir}" />
<mkdir dir="${build.dir}" />
<mkdir dir="${tmp.dir}" />
<!-- ****************************** BUILD LIBRARY **************************** -->
<ant antfile="Util/js-concat-compress.xml">
<property name="compress.input" value="${source.core.js} ${source.languages.js}" />
<property name="compress.output" value="${build.dir}EnlighterJS.min.js" />
<property name="uncompress.output" value="${build.dir}EnlighterJS.js" />
</ant>
<ant antfile="Util/css-concat-compress.xml">
<property name="compress.input" value="${source.css}" />
<property name="compress.output" value="${build.dir}EnlighterJS.min.css" />
<property name="uncompress.output" value="${build.dir}EnlighterJS.css" />
</ant>
<!-- Store JS + CSS Files !-->
<echo message="${source.css}" file=".tmp/css.txt"></echo>
<echo message="${source.core.js} ${source.languages.js}" file=".tmp/js.txt"></echo>
<echo message="${include.languages}" file=".tmp/languages.txt"></echo>
<echo message="${include.themes}" file=".tmp/themes.txt"></echo>
<!-- Change Package Versions !-->
<replaceregexp byline="true" flags="s">
<regexp pattern="current: v(.*)" />
<substitution expression="current: v${build.var.version}"/>
<fileset file="package.yml" />
</replaceregexp>
<replaceregexp byline="true" flags="s">
<regexp pattern="&quot;version&quot;: &quot;v(.*)&quot;" />
<substitution expression="&quot;version&quot;: &quot;v${build.var.version}&quot;"/>
<fileset file="package.json" />
</replaceregexp>
</target>
<target name="webbuild" depends="build">
<!-- Copy files !-->
<copy file="CHANGES.md" tofile="${build.dir}CHANGES.md" />
<copy file="LICENSE.md" tofile="${build.dir}LICENSE.md" />
<copy file="README.md" tofile="${build.dir}README.md" />
<!-- Create Archive !-->
<zip destfile="${build.dir}/EnlighterJS.zip" basedir="${build.dir}" />
</target>
<!-- Generate Examples -->
<target name="examples">
<!-- Cleanup www Dir -->
<delete dir="${example.dir}" />
<mkdir dir="${example.dir}"/>
<!-- Std Examples !-->
<exec executable="php">
<arg value="Util/ExampleGenerator.php" />
<arg value="${example.dir}" />
</exec>
</target>
<!-- Markdown Docs => HTML !-->
<target name="docs">
<!-- Merge Readme - sort by numeric prefix!-->
<echo message="Merging Readme" />
<concat destfile="README.md" fixlastline="yes">
<sort xmlns:rcmp="antlib:org.apache.tools.ant.types.resources.comparators">
<fileset dir="Docs" includes="*.md"/>
<rcmp:name />
</sort>
</concat>
<!-- Copy CONTRIBUTE.md from docs !-->
<copy file="Docs/70-Contribution.md" tofile="CONTRIBUTE.md" />
<!-- Merge Documentation - sort by numeric prefix!-->
<echo message="Merging Docs" />
<concat destfile="${tmp.dir}/Documentation.md" fixlastline="yes">
<fileset dir="Docs/" includes="20*.md, 30*.md, 40*.md, 50*.md, 60*.md, 70*.md, 80*.md" />
</concat>
<!-- Convert Docs to HTML !-->
<echo message="Rendering Markdown Documents" />
<exec executable="php">
<arg line="Util/cli.php markdown ${tmp.dir}/Documentation.md ${tmp.dir}/Documentation.html"></arg>
</exec>
<exec executable="php">
<arg line="Util/cli.php markdown CHANGES.md ${tmp.dir}/Changelog.html"></arg>
</exec>
</target>
<!-- Generate Demo Website !-->
<target name="website">
<!-- Cleanup www Dir -->
<delete dir="${www.dir}" />
<mkdir dir="${www.dir}"/>
<!-- Generate Pages !-->
<exec executable="php">
<arg value="Util/PageGenerator.php" />
<arg value="${www.dir}" />
<arg value="${build.var.version}" />
</exec>
<!-- Generate Examples !-->
<exec executable="php">
<arg value="Util/ExampleGenerator.php" />
<arg value="${www.dir}" />
<arg value="www" />
</exec>
<!-- Copy fonts !-->
<copy todir="${www.dir}/fonts">
<fileset dir="Resources/bootstrap/fonts"/>
</copy>
<copy todir="${www.dir}/img">
<fileset dir="Resources/img"/>
</copy>
<!-- Copy Resources !-->
<copy todir="${www.dir}">
<fileset dir="Resources/bootstrap" includes="bootstrap.min.css"/>
<fileset dir="Resources" includes="MooTools.min.js"/>
<fileset dir="Build" includes="EnlighterJS.min.js,EnlighterJS.min.css"/>
</copy>
<!-- Less CSS build (WEB CSS) !-->
<echo message="Building LESS Files.." />
<exec executable="lessc">
<arg line="Resources/EnlighterWeb.less" />
<arg line="${www.dir}EnlighterWeb.min.css" />
<arg line="--clean-css" />
</exec>
<ant antfile="Util/js-concat-compress.xml">
<property name="compress.input" value="Resources/social-buttons/social-buttons.js Resources/EnlighterWeb.js" />
<property name="compress.output" value="${www.dir}EnlighterWeb.min.js" />
<property name="uncompress.output" value="${tmp.dir}_null" />
</ant>
<!-- Copy Screenshots -->
<copy file="screenshot1.png" tofile="${www.dir}screenshot1.png" />
<copy file="screenshot2.png" tofile="${www.dir}screenshot2.png" />
<!-- Copy Favicon !-->
<copy file="Resources/favicon.png" tofile="${www.dir}favicon.png" />
<!-- Copy License and fix linebreaks !-->
<copy file="LICENSE.md" tofile="${www.dir}LICENSE.txt" />
<fixcrlf eol="crlf" file="${www.dir}LICENSE.txt" />
<!-- Backward Compatibility !-->
<copy file="${www.dir}Theme.Enlighter.html" tofile="${www.dir}Themes.html" />
</target>
<target name="full" depends="build,docs,examples,website" />
<!-- Release new Website Version !-->
<target name="www-upload">
<!-- Credentials, Host Settings !-->
<loadproperties srcFile=".credentials/account.conf" prefix="deploy" />
<!-- transfer deploy plugin !-->
<echo message="Uploading files" />
<scp todir="${deploy.user}@${deploy.host}:www" trust="true" port="${deploy.port}" sftp="true" keyfile="${user.home}/${deploy.keyfile}" passphrase="${deploy.keyfile.passphrase}">
<fileset dir="PublicHtml" />
</scp>
</target>
</project>