Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ html/
output/
mdn/.id-list
mdn/developer.mozilla.org/
node_modules/
highlighter/


Expand Down
72 changes: 48 additions & 24 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ declare -r WATTSI_LATEST=140
# Shared state variables throughout this script
LOCAL_WATTSI=true
WATTSI_RESULT=0
USE_BIKESHED=false
DO_UPDATE=true
DO_LINT=true
DO_HIGHLIGHT=true
Expand Down Expand Up @@ -85,14 +86,16 @@ function main {
exit 0
fi

checkWattsi
ensureHighlighterInstalled
if [[ $USE_BIKESHED != "true" ]]; then
checkWattsi
ensureHighlighterInstalled

doLint
doLint

updateRemoteDataFiles
updateRemoteDataFiles

startHighlightServer
startHighlightServer
fi

processSource "source" "default"

Expand Down Expand Up @@ -146,6 +149,7 @@ function processCommandLineArgs {
echo " $0 help Show this usage statement."
echo
echo "Build options:"
echo " -b|--bikeshed Use Bikeshed instead of Wattsi. (experimental)"
echo " -d|--docker Use Docker to build in a container."
echo " -r|--remote Use the build server."
echo " -s|--serve After building, serve the results on http://localhost:$SERVE_PORT."
Expand Down Expand Up @@ -176,6 +180,10 @@ function processCommandLineArgs {
DO_HIGHLIGHT=false
SINGLE_PAGE_ONLY=true
;;
-b|--bikeshed)
USE_BIKESHED=true
SINGLE_PAGE_ONLY=true
;;
-d|--docker)
USE_DOCKER=true
;;
Expand Down Expand Up @@ -656,34 +664,48 @@ function processSource {
cp -p entities/out/entities-dtd.url "$HTML_CACHE"
runRustTools <"$HTML_SOURCE/$source_location" >"$HTML_TEMP/source-whatwg-complete"

runWattsi "$HTML_TEMP/source-whatwg-complete" "$HTML_TEMP/wattsi-output"
if [[ $WATTSI_RESULT == "0" ]]; then
if [[ $LOCAL_WATTSI != "true" ]]; then
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
fi
if [[ $USE_BIKESHED == "true" ]]; then
clearDir "$HTML_TEMP/bikeshed-output"

node wattsi2bikeshed.js "$HTML_TEMP/source-whatwg-complete" "$HTML_TEMP/source-whatwg-complete.bs"

local bikeshed_args=( --force )
$DO_UPDATE || bikeshed_args+=( --no-update )
bikeshed "${bikeshed_args[@]}" spec "$HTML_TEMP/source-whatwg-complete.bs" "$HTML_TEMP/bikeshed-output/index.html" --md-Text-Macro="SHA $HTML_SHA" --md-Text-Macro="COMMIT-SHA $HTML_SHA"
else
if [[ $LOCAL_WATTSI != "true" ]]; then
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
fi
if [[ $WATTSI_RESULT == "65" ]]; then
echo
echo "There were errors. Running again to show the original line numbers."
echo
runWattsi "$HTML_SOURCE/$source_location" "$HTML_TEMP/wattsi-raw-source-output"
runWattsi "$HTML_TEMP/source-whatwg-complete" "$HTML_TEMP/wattsi-output"
if [[ $WATTSI_RESULT == "0" ]]; then
if [[ $LOCAL_WATTSI != "true" ]]; then
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
fi
else
if [[ $LOCAL_WATTSI != "true" ]]; then
grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
fi
if [[ $WATTSI_RESULT == "65" ]]; then
echo
echo "There were errors. Running again to show the original line numbers."
echo
runWattsi "$HTML_SOURCE/$source_location" "$HTML_TEMP/wattsi-raw-source-output"
if [[ $LOCAL_WATTSI != "true" ]]; then
grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
fi
fi
echo
echo "There were errors. Stopping."
exit "$WATTSI_RESULT"
fi
echo
echo "There were errors. Stopping."
exit "$WATTSI_RESULT"
fi

# Keep the list of files copied from $HTML_SOURCE in sync with `doServerBuild`

if [[ $build_type == "default" ]]; then
# Singlepage HTML
runRustTools --singlepage-post <"$HTML_TEMP/wattsi-output/index-html" >"$HTML_OUTPUT/index.html"
if [[ $USE_BIKESHED == "true" ]]; then
mv "$HTML_TEMP/bikeshed-output/index.html" "$HTML_OUTPUT/index.html"
else
runRustTools --singlepage-post <"$HTML_TEMP/wattsi-output/index-html" >"$HTML_OUTPUT/index.html"
fi

if [[ $SINGLE_PAGE_ONLY == "false" ]]; then
# Singlepage Commit Snapshot
Expand All @@ -699,7 +721,9 @@ function processSource {
fi

cp -p entities/out/entities.json "$HTML_OUTPUT"
cp -p "$HTML_TEMP/wattsi-output/xrefs.json" "$HTML_OUTPUT"
if [[ $USE_BIKESHED == "false" ]]; then
cp -p "$HTML_TEMP/wattsi-output/xrefs.json" "$HTML_OUTPUT"
fi

clearDir "$HTML_TEMP"

Expand Down
Loading
Loading