Skip to content

Commit

Permalink
Add a simple build tool
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberShadow committed May 12, 2011
1 parent a766cf5 commit a1b9ea0
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -24,6 +24,7 @@ RABCDAsm v1.6 (2011.05.??)
input file
* Failure to decode a method body is now not a fatal error
* Aggressively try to shorten double literals to their shortest representation
* The package can now be built using a simple, dedicated build tool
* Documentation updates

RABCDAsm v1.5 (2011.04.14)
Expand Down
16 changes: 8 additions & 8 deletions README.md
Expand Up @@ -50,20 +50,20 @@ Compiling from source

RABCDAsm is written in the [D programming language, version 2][d2].

Assuming you have [dmd][] and [git][] installed, compiling should be as
straight-forward as:
Assuming you have [git][] and a D2 compiler, such as [dmd][] or [gdc][]
installed, compiling should be as straight-forward as:

git clone git://github.com/CyberShadow/RABCDAsm.git
cd RABCDAsm
dmd -O -inline rabcdasm abcfile asprogram disassembler autodata murmurhash2a
dmd -O -inline rabcasm abcfile asprogram assembler autodata murmurhash2a
dmd -O -inline abcexport swffile zlibx
dmd -O -inline abcreplace swffile zlibx
dmd -O -inline swfdecompress swffile zlibx
dmd -O -inline swf7zcompress swffile zlibx
dmd -run build_rabcdasm

Substitute `dmd` with `gdmd` if you're using gdc. You can use the `DC` and
`DCFLAGS` environment variables to override the detected compiler and default
compilation flags (`-O -inline`).

[d2]: http://www.digitalmars.com/d/2.0/
[dmd]: http://www.digitalmars.com/d/download.html
[gdc]: http://bitbucket.org/goshawk/gdc/
[git]: http://git-scm.com/

Pre-compiled binaries
Expand Down
67 changes: 67 additions & 0 deletions build_rabcdasm.d
@@ -0,0 +1,67 @@
/*
* Copyright (C) 2010 Vladimir Panteleev <vladimir@thecybershadow.net>
* This file is part of RABCDAsm.
*
* RABCDAsm is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RABCDAsm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RABCDAsm. If not, see <http://www.gnu.org/licenses/>.
*/

// A simple tool to build RABCDAsm in one command.
// You can use the DC and DFLAGS environment variables to override the detected compiler and compilation flags.

version(D_Version2)
{ /* All OK */ }
else
static assert(false, "Unsupported D version.\nThis software requires a D2 ( http://www.digitalmars.com/d/2.0/ ) compiler to build.");

version(DigitalMars)
const DEFAULT_COMPILER = "dmd";
else
const DEFAULT_COMPILER = "gdmd";

const DEFAULT_FLAGS = "-O -inline";

import std.process;
import std.string;

string[][string] programs;

static this()
{
programs["rabcasm" ] = ["abcfile", "asprogram", "assembler", "autodata", "murmurhash2a"];
programs["rabcdasm" ] = ["abcfile", "asprogram", "disassembler", "autodata", "murmurhash2a"];
programs["abcexport" ] = ["swffile", "zlibx"];
programs["abcreplace" ] = ["swffile", "zlibx"];
programs["swfdecompress"] = ["swffile", "zlibx"];
programs["swf7zcompress"] = ["swffile", "zlibx"];
}

int main()
{
string compiler = getenv("DC");
if (compiler is null)
compiler = DEFAULT_COMPILER;

string flags = getenv("DCFLAGS");
if (flags is null)
flags = DEFAULT_FLAGS;

foreach (program, modules; programs)
{
int ret = system(format("%s %s %s %s", compiler, flags, program, join(modules, " ")));
if (ret)
return ret;
}

return 0;
}

0 comments on commit a1b9ea0

Please sign in to comment.