Browse Source

tools/concat.lua -> tools/build.lua;

The first argument is now a build type instead of a destination file.
The build type can either be "base" or "luvit" and defaults to "base".
bjorn 9 years ago
parent
commit
c599ac6d19
2 changed files with 34 additions and 8 deletions
  1. 3 2
      doc/CONTRIBUTING.md
  2. 31 6
      tools/build.lua

+ 3 - 2
doc/CONTRIBUTING.md

@@ -11,9 +11,10 @@ Tooling
 
 
 There are a number of scripts in the `tools` folder that automate certain tasks.  In general, they are run using `lua tools/<file>.lua` from the project root and take no arguments.
 There are a number of scripts in the `tools` folder that automate certain tasks.  In general, they are run using `lua tools/<file>.lua` from the project root and take no arguments.
 
 
-- Everything in the `src` directory is concatenated into a single `rx.lua` file in the project root.  The file `tools/concat.lua` does this concatenation.  It strips out both the requires at the top of files and the return values at the bottom.
+- Everything in the `src` directory is concatenated into a single `rx.lua` file in the project root.  The file `tools/build.lua` does this concatenation.  It strips out both the requires at the top of files and the return values at the bottom.
+  - If you want to create a luvit build with additional features, you can run `lua tools/build.lua luvit`.
 - The documentation in `doc/README.md` is automatically generated based on comments in the source.  The file `tools/update_documentation.lua` performs this generation.  Internally it uses `docroc`, which is a library that parses Lua comments and returns them in a table.  From here, `update_documentation` converts the table to markdown and writes it to the `doc` directory.
 - The documentation in `doc/README.md` is automatically generated based on comments in the source.  The file `tools/update_documentation.lua` performs this generation.  Internally it uses `docroc`, which is a library that parses Lua comments and returns them in a table.  From here, `update_documentation` converts the table to markdown and writes it to the `doc` directory.
-- Currently, you should run both of these scripts and include an updated `rx.lua` and `doc/README.md` as part of a pull request.  If you've added a new file you'll have to add it (alphabetized) to the file list in `tools/concat.lua`.
+- Currently, you should run both of these scripts and include an updated `rx.lua` and `doc/README.md` as part of a pull request.  If you've added a new file you'll have to add it (alphabetized) to the file list in `tools/build.lua`.
 
 
 Tests
 Tests
 ---
 ---

+ 31 - 6
tools/concat.lua → tools/build.lua

@@ -1,5 +1,6 @@
--- Horrible script to concatenate everything in /src into a single rx.lua file.
--- Usage: lua tools/concat.lua [dest=rx.lua]
+--- Horrible script to concatenate everything in /src into a single rx.lua file.
+-- @usage lua tools/build.lua [distribution=base]
+-- @arg {string='base'} distribution - Type of distribution to build, either 'base' or 'luvit'.
 
 
 local files = {
 local files = {
   'src/util.lua',
   'src/util.lua',
@@ -66,12 +67,22 @@ local files = {
 }
 }
 
 
 local header = [[
 local header = [[
--- RxLua v0.0.1
+-- RxLua v0.0.2
 -- https://github.com/bjornbytes/rxlua
 -- https://github.com/bjornbytes/rxlua
 -- MIT License
 -- MIT License
 
 
 ]]
 ]]
 
 
+local exports = [[
+exports.name = 'bjornbytes/rx'
+exports.version = '0.0.2'
+exports.description = 'Reactive Extensions for Lua'
+exports.license = 'MIT'
+exports.author = { url = 'https://github.com/bjornbytes' }
+exports.homepage = 'https://github.com/bjornbytes/rxlua'
+
+]]
+
 local footer = [[return {
 local footer = [[return {
   util = util,
   util = util,
   Subscription = Subscription,
   Subscription = Subscription,
@@ -104,8 +115,22 @@ for _, filename in ipairs(files) do
   output = output .. str .. '\n\n'
   output = output .. str .. '\n\n'
 end
 end
 
 
-local outputFile = arg[1] or 'rx.lua'
-local file = io.open(outputFile, 'w')
+local distribution = arg[1] or 'base'
+local destination, components
+
+if distribution == 'base' then
+  destination = 'rx.lua'
+  components = { header, output, footer }
+elseif distribution == 'luvit' then
+  destination = 'rx-luvit.lua'
+  components = { header, exports, output, footer }
+else
+  error('Invalid distribution specified.')
+end
+
+local file = io.open(destination, 'w')
+
 if file then
 if file then
-  file:write(header .. output .. footer)
+  file:write(table.concat(components, ''))
+  file:close()
 end
 end