Dropped js replace tool.

This commit is contained in:
Brad Nelson
2023-12-22 20:46:23 -08:00
parent 3c0f249b71
commit c475681b0e
12 changed files with 105 additions and 205 deletions

163
Makefile
View File

@ -240,94 +240,81 @@ $(GEN):
mkdir -p $@
$(GEN)/posix_boot.h: posix/posix_boot.fs | $(GEN)
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
-I . -I $(GEN) --name boot --header cpp --depsout $@.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/posix_boot.h.dd
$(GEN)/windows_boot_extra.h: windows/windows_boot_extra.fs | $(GEN)
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
-I . -I $(GEN) --name boot_extra --header win --depsout $@.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/windows_boot_extra.h.dd
$(GEN)/windows_boot.h: windows/windows_boot.fs | $(GEN)
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
-I . -I $(GEN) --name boot --header win --depsout $@.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/windows_boot.h.dd
$(GEN)/pico_ice_boot.h: pico-ice/pico_ice_boot.fs | $(GEN)
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
-I . -I $(GEN) --name boot --header cpp --depsout $@.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/pico_ice_boot.h.dd
$(GEN)/esp32_boot.h: esp32/esp32_boot.fs | $(GEN)
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
-I . -I $(GEN) --name boot --header cpp --depsout $@.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_boot.h.dd
$(GEN)/esp32_assembler.h: common/assembler.fs | $(GEN)
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
-I . -I $(GEN) --name assembler_source --header cpp --depsout $@.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_assembler.h.dd
$(GEN)/esp32_xtensa-assembler.h: esp32/optional/assemblers/xtensa-assembler.fs | $(GEN)
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
-I . -I $(GEN) --name xtensa_assembler_source --header cpp --depsout $@.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_xtensa-assembler.h.dd
$(GEN)/esp32_riscv-assembler.h: esp32/optional/assemblers/riscv-assembler.fs | $(GEN)
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
-I . -I $(GEN) --name riscv_assembler_source --header cpp --depsout $@.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_riscv-assembler.h.dd
$(GEN)/esp32_camera.h: esp32/optional/camera/camera_server.fs | $(GEN)
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
-I . -I $(GEN) --name camera_source --header cpp --depsout $@.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_camera.h.dd
$(GEN)/esp32_interrupts.h: esp32/optional/interrupts/timers.fs | $(GEN)
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
-I . -I $(GEN) --name interrupts_source --header cpp --depsout $@.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_interrupts.h.dd
$(GEN)/esp32_oled.h: esp32/optional/oled/oled.fs | $(GEN)
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
-I . -I $(GEN) --name oled_source --header cpp --depsout $@.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_oled.h.dd
$(GEN)/esp32_spi-flash.h: esp32/optional/spi-flash/spi-flash.fs | $(GEN)
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
-I . -I $(GEN) --name spi_flash_source --header cpp --depsout $@.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_spi-flash.h.dd
$(GEN)/esp32_serial-bluetooth.h: esp32/optional/serial-bluetooth/serial-bluetooth.fs | $(GEN)
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
-I . -I $(GEN) --name serial_blueooth_source --header cpp --depsout $@.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_serial-bluetooth.h.dd
OPTIONAL_MODULES = \
@ -361,10 +348,9 @@ $(GEN)/web_sys.js: $(GEN)/dump_web_opcodes | $(GEN)
$< sys >$@
$(GEN)/web_boot.js: web/web_boot.fs | $(GEN)
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
-I . -I $(GEN) --name boot --header web --depsout $@.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/web_boot.js.dd
# ---- RESOURCES ----
@ -464,7 +450,7 @@ $(WINDOWS)/uEf32.obj: \
windows/main.c \
$(GEN)/windows_boot_extra.h \
$(GEN)/windows_boot.h | $(WINDOWS)
./tools/importation.py $< $@ --no-out -I . -I $(GEN) --depsout $@.dd
./tools/importation.py -i $< -o $@ --no-out -I . -I $(GEN) --depsout $@.dd
$(CL32) /c /Fo$@ $(WIN_CFLAGS) $<
-include $(WINDOWS)/uEf32.obj.dd
@ -477,7 +463,7 @@ $(WINDOWS)/uEf64.obj: \
windows/main.c \
$(GEN)/windows_boot_extra.h \
$(GEN)/windows_boot.h | $(WINDOWS)
./tools/importation.py $< $@ --no-out -I . -I $(GEN) --depsout $@.dd
./tools/importation.py -i $< -o $@ --no-out -I . -I $(GEN) --depsout $@.dd
$(CL64) /c /Fo$@ $(WIN_CFLAGS) $<
-include $(WINDOWS)/uEf64.obj.dd
@ -523,91 +509,81 @@ $(ESP32)/ESP32forth/optional:
$(ESP32)/ESP32forth/ESP32forth.ino: \
esp32/ESP32forth.ino \
$(GEN)/esp32_boot.h | $(ESP32)/ESP32forth
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
--keep-first-comment \
-I . -I $(GEN) --depsout $(GEN)/esp32.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32.dd
$(ESP32)/ESP32forth/README.txt: esp32/README.txt | $(ESP32)/ESP32forth
./tools/importation.py $< $@ \
--set-version $(VERSION) \
--set-revision $(REVISION)
./tools/importation.py -i $< -o $@ \
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
$(ESP32)/ESP32forth/optional/README-optional.txt: \
esp32/optional/README-optional.txt | $(ESP32)/ESP32forth/optional
./tools/importation.py $< $@ \
--set-version $(VERSION) \
--set-revision $(REVISION)
./tools/importation.py -i $< -o $@ \
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
$(ESP32)/ESP32forth/optional/assemblers.h: \
esp32/optional/assemblers/assemblers.h \
$(GEN)/esp32_assembler.h \
$(GEN)/esp32_xtensa-assembler.h \
$(GEN)/esp32_riscv-assembler.h | $(ESP32)/ESP32forth/optional
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
--keep-first-comment \
-I . -I $(GEN) --depsout $(GEN)/esp32_optional_assemblers.h.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_optional_assemblers.h.dd
$(ESP32)/ESP32forth/optional/camera.h: \
esp32/optional/camera/camera.h \
$(GEN)/esp32_camera.h | $(ESP32)/ESP32forth/optional
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
--keep-first-comment \
-I . -I $(GEN) --depsout $(GEN)/esp32_optional_camera.h.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_optional_camera.h.dd
$(ESP32)/ESP32forth/optional/interrupts.h: \
esp32/optional/interrupts/interrupts.h \
$(GEN)/esp32_interrupts.h | $(ESP32)/ESP32forth/optional
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
--keep-first-comment \
-I . -I $(GEN) --depsout $(GEN)/esp32_optional_interrupts.h.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_optional_interrupts.h.dd
$(ESP32)/ESP32forth/optional/oled.h: \
esp32/optional/oled/oled.h \
$(GEN)/esp32_oled.h | $(ESP32)/ESP32forth/optional
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
--keep-first-comment \
-I . -I $(GEN) --depsout $(GEN)/esp32_optional_oled.h.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_optional_oled.h.dd
$(ESP32)/ESP32forth/optional/rmt.h: \
esp32/optional/rmt.h | $(ESP32)/ESP32forth/optional
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
--keep-first-comment \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
$(ESP32)/ESP32forth/optional/serial-bluetooth.h: \
esp32/optional/serial-bluetooth/serial-bluetooth.h \
$(GEN)/esp32_serial-bluetooth.h | $(ESP32)/ESP32forth/optional
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
--keep-first-comment \
-I . -I $(GEN) --depsout $(GEN)/esp32_optional_serial-bluetooth.h.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_optional_serial-bluetooth.h.dd
$(ESP32)/ESP32forth/optional/spi-flash.h: \
esp32/optional/spi-flash/spi-flash.h \
$(GEN)/esp32_spi-flash.h | $(ESP32)/ESP32forth/optional
./tools/importation.py $< $@ \
./tools/importation.py -i $< -o $@ \
--keep-first-comment \
-I . -I $(GEN) --depsout $(GEN)/esp32_optional_spi-flash.h.dd \
--set-version $(VERSION) \
--set-revision $(REVISION)
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
-include $(GEN)/esp32_optional_spi-flash.h.dd
# ---- ESP32 ARDUINO BUILD AND FLASH ----
@ -712,9 +688,8 @@ pico-ice/pico-ice-sdk/README.md:
git submodule update --init pico-ice/pico-ice-sdk
$(PICO_ICE)/ueforth-pico-ice/README.txt: pico-ice/README.txt | $(PICO_ICE)/ueforth-pico-ice
./tools/importation.py $< $@ \
--set-version $(VERSION) \
--set-revision $(REVISION)
./tools/importation.py -i $< -o $@ \
-DVERSION=$(VERSION) -DREVISION=$(REVISION)
$(PICO_ICE)/ueforth-pico-ice/LICENSE: LICENSE
cp $< $@
@ -830,18 +805,12 @@ publish: publish-esp32 publish-pico-ice publish-linux publish-web publish-window
$(DEPLOY):
mkdir -p $@
REPLACE = tools/replace.js \
HEAD=@site/head.html \
COMMON=@site/common.html \
FILES_COMMON=@site/files_common.html \
POSIX_COMMON=@site/posix_common.html \
DESKTOP_COMMON=@site/desktop_common.html \
MENU=@site/menu.html \
VERSION=${VERSION} \
STABLE_VERSION=${STABLE_VERSION} \
OLD_STABLE_VERSION=${OLD_STABLE_VERSION}
UE_REPLACE = $(REPLACE) FORTH=uEForth
ESP_REPLACE = $(REPLACE) FORTH=ESP32forth
REPLACE = ./tools/importation.py -I site \
-DVERSION=${VERSION} \
-DSTABLE_VERSION=${STABLE_VERSION} \
-DOLD_STABLE_VERSION=${OLD_STABLE_VERSION}
UE_REPLACE = $(REPLACE) -DFORTH=uEForth
ESP_REPLACE = $(REPLACE) -DFORTH=ESP32forth
$(DEPLOY)/app.yaml: $(RES)/eforth.ico \
$(wildcard site/*.html) \
@ -857,14 +826,14 @@ $(DEPLOY)/app.yaml: $(RES)/eforth.ico \
cp site/*.yaml $(DEPLOY)/
cp site/.gcloudignore $(DEPLOY)
cp out/web/ueforth.js $(DEPLOY)/
cat site/web.html | $(ESP_REPLACE) >$(DEPLOY)/web.html
cat site/ESP32forth.html | $(ESP_REPLACE) >$(DEPLOY)/ESP32forth.html
cat site/pico-ice.html | $(UE_REPLACE) >$(DEPLOY)/pico-ice.html
cat site/index.html | $(UE_REPLACE) >$(DEPLOY)/index.html
cat site/linux.html | $(UE_REPLACE) >$(DEPLOY)/linux.html
cat site/windows.html | $(UE_REPLACE) >$(DEPLOY)/windows.html
cat site/internals.html | $(UE_REPLACE) >$(DEPLOY)/internals.html
cat site/classic.html | $(UE_REPLACE) >$(DEPLOY)/classic.html
$(ESP_REPLACE) -i site/web.html -o $(DEPLOY)/web.html
$(ESP_REPLACE) -i site/ESP32forth.html -o $(DEPLOY)/ESP32forth.html
$(UE_REPLACE) -i site/pico-ice.html -o $(DEPLOY)/pico-ice.html
$(UE_REPLACE) -i site/index.html -o $(DEPLOY)/index.html
$(UE_REPLACE) -i site/linux.html -o $(DEPLOY)/linux.html
$(UE_REPLACE) -i site/windows.html -o $(DEPLOY)/windows.html
$(UE_REPLACE) -i site/internals.html -o $(DEPLOY)/internals.html
$(UE_REPLACE) -i site/classic.html -o $(DEPLOY)/classic.html
deploy: all
cd out/deploy && gcloud app deploy -q --project esp32forth *.yaml

View File

@ -16,13 +16,13 @@ limitations under the License.
-->
<head>
{{HEAD}}
#include "head.html"
<title>ESP32forth</title>
</head>
<body>
<h1>ESP32forth</h1>
{{MENU}}
#include "menu.html"
<div class="wrapper">
<h2>Download</h2>
@ -322,9 +322,9 @@ On boot, ESP32forth configures PIN 2 (typically an LED) to be an output and brin
<h3>ESP32forth Specific Words</h3>
{{COMMON}}
{{FILES_COMMON}}
{{POSIX_COMMON}}
#include "common.html"
#include "files_common.html"
#include "posix_common.html"
<h3>ESP32forth Bindings</h3>

View File

@ -15,13 +15,13 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
{{HEAD}}
#include "head.html"
<title>Classic EForth</title>
</head>
<body>
<h1>Classic EForth</h1>
{{MENU}}
#include "menu.html"
<div class="wrapper">
<p>

View File

@ -16,7 +16,7 @@ limitations under the License.
-->
<head>
{{HEAD}}
#include "head.html"
<title>EForth</title>
</head>
@ -26,7 +26,7 @@ limitations under the License.
window.location.replace('./ESP32forth.html');
</script>
{{MENU}}
#include "menu.html"
<div class="wrapper">
<p>

View File

@ -16,13 +16,13 @@ limitations under the License.
-->
<head>
{{HEAD}}
#include "head.html"
<title>µEforth Internals</title>
</head>
<body>
<h1>µEforth Internals</h1>
{{MENU}}
#include "menu.html"
<div class="wrapper">
<p>

View File

@ -16,13 +16,13 @@ limitations under the License.
-->
<head>
{{HEAD}}
#include "head.html"
<title>µEforth for Linux</title>
</head>
<body>
<h1>µEforth for Linux</h1>
{{MENU}}
#include "menu.html"
<div class="wrapper">
<h2>Download</h2>
@ -63,9 +63,9 @@ limitations under the License.
<h3>µEforth Words</h3>
{{COMMON}}
{{FILES_COMMON}}
{{POSIX_COMMON}}
#include "common.html"
#include "files_common.html"
#include "posix_common.html"
<h3>Linux</h3>
@ -101,4 +101,4 @@ In addition, <code>TYPE</code> and <code>KEY</code> are connected to
<code>stdin</code> and <code>stdout</code>.
</p>
{{DESKTOP_COMMON}}
#include "desktop_common.html"

View File

@ -16,13 +16,13 @@ limitations under the License.
-->
<head>
{{HEAD}}
#include "head.html"
<title>pico-ice</title>
</head>
<body>
<h1>pico-ice</h1>
{{MENU}}
#include "menu.html"
<div class="wrapper">
<h2>Download</h2>
@ -103,7 +103,7 @@ Be sure to config the serial port to: <code>baud rate = 115200, data bits = 8, s
<h3>pico-ice Words</h3>
{{COMMON}}
#include "common.html"
<h3>pico-ice Bindings</h3>

View File

@ -16,13 +16,13 @@ limitations under the License.
-->
<head>
{{HEAD}}
#include "head.html"
<title>µEforth for Web</title>
</head>
<body>
<h1>µEforth for Web</h1>
{{MENU}}
#include "menu.html"
<div class="web_wrapper">
<div id="ueforth"></div>

View File

@ -16,13 +16,13 @@ limitations under the License.
-->
<head>
{{HEAD}}
#include "head.html"
<title>µEforth for Windows</title>
</head>
<body>
<h1>µEforth for Windows</h1>
{{MENU}}
#include "menu.html"
<div class="wrapper">
<h2>Download</h2>
@ -69,8 +69,8 @@ limitations under the License.
<h3>µEforth Words</h3>
{{COMMON}}
{{FILES_COMMON}}
#include "common.html"
#include "files_common.html"
<h3>Windows</h3>
@ -110,4 +110,4 @@ In addition, a terminal that responds to ANSI escape codes is created and connec
<code>TYPE</code> and <code>KEY</code>.
</p>
{{DESKTOP_COMMON}}
#include "desktop_common.html"

View File

@ -97,7 +97,7 @@ rule mkdir
rule importation
description = importation
depfile = $out.dd
command = ../tools/importation.py $in $out -I . -I .. --name $name --header $header_mode --depsout $out.dd --set-version $version --set-revision $revision
command = ../tools/importation.py -i $in -o $out -I . -I .. --name $name --header $header_mode --depsout $out.dd -DVERSION=$version -DREVSION=$revision
build gen: mkdir

View File

@ -7,11 +7,10 @@ import sys
parser = argparse.ArgumentParser(
prog='importation',
description='Imports header / fs files')
parser.add_argument('input')
parser.add_argument('output')
parser.add_argument('-i', required=True)
parser.add_argument('-o', required=True)
parser.add_argument('-I', action='append')
parser.add_argument('--set-version')
parser.add_argument('--set-revision')
parser.add_argument('-D', action='append')
parser.add_argument('--depsout')
parser.add_argument('--no-out', action='store_true')
parser.add_argument('--keep-first-comment', action='store_true')
@ -19,6 +18,7 @@ parser.add_argument('--name')
parser.add_argument('--header')
args = parser.parse_args()
bases = args.I or []
replacements = args.D or []
results = []
imported = set([__file__])
@ -36,6 +36,7 @@ def Import(filename):
sfilename = os.path.join(os.path.dirname(filename), sfilename)
Import(sfilename)
elif (filename.endswith('.h') or
filename.endswith('.html') or
filename.endswith('.ino') or
filename.endswith('.cc') or
filename.endswith('.cpp') or
@ -54,14 +55,13 @@ def Import(filename):
results.append(line)
def Process():
Import(args.input)
Import(args.i)
# Conversion version tags.
output = []
for line in results:
if args.set_version:
line = line.replace('{{VERSION}}', args.set_version)
if args.set_revision:
line = line.replace('{{REVISION}}', args.set_revision)
for r in replacements:
name, value = r.split('=', 1)
line = line.replace('{{' + name + 'VERSION}}', value)
output.append(line)
# Drop comments.
comment1 = False
@ -85,11 +85,11 @@ def Process():
# Emit deps.
if args.depsout:
with open(args.depsout, 'w') as fh:
fh.write(args.output + ': ' +
fh.write(args.o + ': ' +
' '.join([os.path.relpath(i) for i in imported]) + '\n')
# Emit expanded file.
if not args.no_out:
with open(args.output, 'w') as fh:
with open(args.o, 'w') as fh:
if args.header == 'web':
fh.write('const ' + args.name + ' = `\n' +
'\n'.join(output) + '\n`;\n')

View File

@ -1,69 +0,0 @@
#! /usr/bin/env nodejs
// Copyright 2021 Bradley D. Nelson
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var fs = require('fs');
function DropCopyright(source) {
var lines = source.split('\n');
var cleaned = [];
for (var i = 0; i < lines.length; ++i) {
if (lines[i] == '<!--') {
while (lines[i] != '-->') {
++i;
}
++i;
}
if (lines[i].search('Copyright') >= 0) {
while (lines[i] != '') {
++i;
}
} else {
cleaned.push(lines[i]);
}
}
return cleaned.join('\n').trim();
}
var source = fs.readFileSync(process.stdin.fd).toString();
var replacements = [];
for (var i = 2; i < process.argv.length; ++i) {
var item = process.argv[i];
var m = item.match(/^([^=]+)=@(.+)$/);
if (m) {
var content = DropCopyright(fs.readFileSync(m[2]).toString());
replacements.push(['{{' + m[1] + '}}', content]);
continue;
}
var m = item.match(/^([^=]+)=(.+)$/);
if (m) {
replacements.push(['{{' + m[1] + '}}', m[2]]);
continue;
}
throw 'Bad replacement ' + item;
}
for (;;) {
var old_source = source;
for (var i = 0; i < replacements.length; ++i) {
source = source.replace(
replacements[i][0],
function() { return replacements[i][1]});
}
if (old_source == source) {
break;
}
}
process.stdout.write(source);