Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

756 lines (691 sloc) 24.199 kb
$loadlib "io_ops";
class OS;
function setup_main(var argv)
{
setup_distutils();
var rosella = {
"name" : 'Rosella',
"abstract" : 'Utilities Library for Parrot',
"authority" : 'http://github.com/Whiteknight',
"copyright_holder" : 'Andrew Whitworth',
"keywords" : ["test", "tap", "xunit", "event", "container", "dependency injection"],
"license_type" : 'Artistic License 2.0',
"license_uri" : 'http://www.perlfoundation.org/artistic_license_2_0',
"checkout_uri" : 'git://github.com/Whiteknight/rosella.git',
"browser_uri" : 'git://github.com/Whiteknight/rosella',
"project_uri" : 'git://github.com/Whiteknight/rosella',
"pir_nqp-rx" : {},
"pir_winxed" : {},
"pbc_pbc" : {},
"pbc_pir" : {},
"pir_pir" : {},
"winxed_debug" : false,
"winxed_winxed" : {},
"inst_lib" : [],
"installable_pbc" : {},
"include_winxed" : {},
"manifest_includes" : ["CREDITS", "README.md", "setup.winxed"]
};
setup_release(rosella);
setup_stable_libraries(rosella);
setup_experimental_libraries(rosella);
setup_utilities(rosella);
setup_data_files(rosella);
setup_include_headers(rosella);
get_all_tests(rosella, "t");
argv.shift();
setup(argv, rosella);
}
function setup_release(var rosella)
{
//rosella["pir_winxed"]["setup.pir"] = "setup.winxed";
//rosella["manifest_includes"].push("setup.pir");
}
function setup_stable_libraries(var rosella)
{
// A distutils wrapper library which adds winxed functionality.
// A bootstrapped version is included in the repo because we need it
// to run setup.winxed (this script). This is the only rosella library
// which doesn't rely on Core.
setup_winxed_lib(rosella, "winxed", [],
"winxed/Distutils"
);
// The Rosella "core" library. Does very little on its own but is
// required by other libraries in the sequence
setup_winxed_lib(rosella, "core", [],
"core/Includes",
"core/Rosella",
"core/Error",
"core/Hash",
"core/Function",
"core/IO",
"core/IteratorBase",
"core/Globals",
"core/ObjectFactory",
"core/Version",
"core/StringFormatter",
"core/Parrot",
"_build/_versions"
);
// The action library. Allows creating Action/Command objects for
// delayed evaluation.
setup_winxed_lib(rosella, "action", ["Core"],
"action/Action",
"action/action/Sub",
"action/action/Method",
"action/Argument",
"action/argument/Instance"
);
// Dependency Injection / Inversion of Control container library
setup_winxed_lib(rosella, "container", ["Core"],
"container/Container",
"container/Argument",
"container/LifetimeManager",
"container/Option",
"container/Resolver",
"container/ServiceLocator"
);
// A proxying library for building and managing proxies
setup_winxed_lib(rosella, "proxy", ["Core"],
"proxy/Builder",
"proxy/Controller",
"proxy/Factory",
"proxy/Proxy",
"proxy/builder/Array",
"proxy/builder/AttributeIntercept",
"proxy/builder/Imitate",
"proxy/builder/Immutable",
"proxy/builder/InvokeIntercept",
"proxy/builder/MethodIntercept",
"proxy/builder/Passthrough",
"proxy/builder/PMCKeyedHash",
"proxy/builder/ProxyData",
"proxy/builder/StringKeyedHash"
);
// A testing library for writing and running unit tests.
setup_winxed_lib(rosella, "test", ["Core"],
"test/Builder",
"test/Asserter",
"test/Failure",
"test/Listener",
"test/Listener/TAP",
"test/Matcher",
"test/matcher/Factory",
"test/Result",
"test/Suite",
"test/SuiteFactory",
"test/suitefactory/List",
"test/suitefactory/Vector",
"test/Test",
"test/TestCase",
"test/TestContext",
"test/TestFactory",
"test/TestStatus"
);
// A mock object library for advanced unit testing
setup_winxed_lib(rosella, "mockobject", ["Core", "Test", "Proxy"],
"mockobject/MockObject",
"mockobject/Controller",
"mockobject/controller/Ordered",
"mockobject/Expectation",
"mockobject/expectation/Get",
"mockobject/expectation/Set",
"mockobject/expectation/Method",
"mockobject/expectation/Invoke",
"mockobject/expectation/Will",
"mockobject/expectation/With",
"mockobject/Factory"
);
// A tap harness library for building easy, extensible test harnesses
setup_winxed_lib(rosella, "harness", ["Core", "FileSystem", "Query", "String", "Container"],
"harness/Harness",
"harness/FileResult",
"harness/TapParser",
"harness/TestExecutor",
"harness/TestFile",
"harness/testfile/Automatic",
"harness/testfile/Factory",
"harness/testfile/NQP",
"harness/testfile/PIR",
"harness/testfile/Winxed",
"harness/TestRun",
"harness/testrun/Factory",
"harness/View"
);
// Event library. Subscribe to, receive, and publish event notifications.
setup_winxed_lib(rosella, "event", ["Core"],
"event/Event",
"event/Dispatcher",
"event/dispatcher/Factory",
"event/Manager",
"event/Payload",
"event/Subscriber",
"event/subscriber/Factory"
);
// Memoization library. Allows multiple types of transparent Sub
// memoization.
setup_winxed_lib(rosella, "memoize", ["Core", "Proxy"],
"memoize/Memoize",
"memoize/Cache",
"memoize/cache/Item",
"memoize/cache/SimpleString",
"memoize/Controller",
"memoize/Factory"
);
// A library for working with aggregates
setup_winxed_lib(rosella, "query", ["Core", "Random"],
"query/Includes",
"query/Query",
"query/Provider",
"query/provider/Array",
"query/provider/Hash",
"query/provider/Scalar",
"query/provider/Factory",
"query/Queryable",
"query/Iterable",
"query/iterable/Factory",
"query/iterable/KeyValuePair",
"query/iterable/Sources",
"query/iterable/Iterators",
"query/Sort",
"query/sort/Timsort"
);
// A library for working with files and directories
setup_winxed_lib(rosella, "filesystem", ["Core", "Math_Builtins", "Date"],
"filesystem/Includes",
"filesystem/FileSystem",
"filesystem/Entry",
"filesystem/Directory",
"filesystem/DirectoryIterator",
"filesystem/File",
"filesystem/FileIterator",
"filesystem/IterableHandle",
"filesystem/Path",
"filesystem/Visitor",
"filesystem/visitor/Delete",
"filesystem/visitor/Function",
"filesystem/visitor/List",
["filesystem/Constants"]:[named("constants")]
);
// Search for values in nested aggregates
setup_winxed_lib(rosella, "path", ["Core"],
"path/Path",
"path/Searcher",
"path/searcher/Hash",
"path/searcher/Attribute"
);
// String handling and tokenizing library
setup_winxed_lib(rosella, "string", ["Core"],
"string/Includes",
"string/String",
"string/FormatPrinter",
"string/Tokenizer",
"string/tokenizer/CClass",
"string/tokenizer/Delimiter",
"string/tokenizer/DelimiterRegion",
"string/tokenizer/Iterator",
"string/tokenizer/SimpleCode",
"string/tokenizer/Token",
"string/Trie"
);
// Templating and formatting text
setup_winxed_lib(rosella, "template", ["Core", "Path", "String", "FileSystem"],
"template/Includes",
"template/Template",
"template/Engine",
"template/Context",
"template/Handler",
"template/handler/Factory",
"template/handler/For",
"template/handler/Repeat",
"template/handler/If",
"template/handler/Include",
"template/handler/Set",
"template/Node",
"template/node/Factory",
"template/node/Master",
"template/node/Logic",
"template/node/Data",
"template/node/Eval",
"template/node/Literal"
);
// Random number generation and tools
setup_winxed_lib(rosella, "random", ["String", "Math_Builtins"],
"random/Includes",
"random/Random",
"random/RandomNumber",
"random/randomnumber/BoxMullerNormal",
"random/randomnumber/MersenneTwister",
"random/UUID",
"random/uuid/Version4"
);
// Working with commandline arguments
setup_winxed_lib(rosella, "commandline", ["Core", "String"],
"commandline/Arguments",
"commandline/Program",
"commandline/ProgramMode"
);
// Library for debug-style data dumping
setup_winxed_lib(rosella, "dumper", ["Core"],
"dumper/Dumper",
"dumper/DumpHandler",
"dumper/Emitter",
"dumper/dumphandler/Array",
"dumper/dumphandler/Hash",
"dumper/dumphandler/InspectAttrs",
"dumper/dumphandler/Object",
"dumper/dumphandler/Null",
"dumper/Handle"
);
// Library for working with date and time
setup_winxed_lib(rosella, "date", ["Core", "Ascii", "Parse_builtins", "Parse"],
"date/Includes",
"date/Date",
"date/DateFormatter",
"date/Doomsday",
"date/ISO8601_101",
"date/SpecialDate",
"date/TimeSpan",
"date/TimeSpanFormatter"
);
// Library for reflection and introspection
setup_winxed_lib(rosella, "reflect", ["Core"],
"reflect/Includes",
"reflect/Reflect",
"reflect/Class",
"reflect/class/Member",
"reflect/class/Attribute",
"reflect/class/Method",
"reflect/Deserializer",
"reflect/Function",
"reflect/Instruction",
"reflect/Module",
"reflect/OpArg"
);
setup_winxed_lib(rosella, "parse", ["Core", "Ascii", "Parse_builtins"],
"parse/Parse"
);
setup_winxed_lib(rosella, "json", ["Core", "Ascii", "Parse_builtins", "Parse", "Dumper"],
"json/Includes",
"json/Json",
"json/Builder",
"json/builder/Factory",
"json/builder/DataObject",
"json/Dumper",
"json/DumpHandler",
"json/Parser"
);
setup_winxed_lib(rosella, "net", ["Core", "Math_Builtins", "Ascii", "Parse_builtins", "Parse", "String", "FileSystem", "Date", "Random"],
"net/Includes",
"net/Net",
"net/Http",
"net/RequestResponse",
"net/http/Header",
"net/http/Request",
"net/http/Response",
"net/MimeBase64",
"net/Protocol",
"net/protocol/Factory",
"net/protocol/File",
"net/protocol/Http",
"net/Uri",
"net/uri/Factory",
"net/uri/File",
"net/uri/Http",
"net/UserAgent",
"net/useragent/SimpleHttp",
"net/SocketFactory"
);
setup_winxed_lib(rosella, "xml", ["Core", "Ascii", "Parse_builtins", "Parse", "String", "FileSystem", "Query"],
"xml/Includes",
"xml/Xml",
"xml/Document",
"xml/Parser",
"xml/Tag",
"xml/tag/Collection",
"xml/Text",
"xml/Visitor"
);
}
function setup_experimental_libraries(var rosella)
{
// A prototype library for managing a prototype-based object system
setup_unstable_lib(rosella, "prototype", ["Core"],
"prototype/Object",
"prototype/Manager",
"prototype/manager/Entry",
"prototype/manager/ObjectCloner"
);
// A library for creating and using cheap, transparent decorator
setup_unstable_lib(rosella, "decorate", ["Core", "Proxy"],
"decorate/Builder",
"decorate/Decorator",
"decorate/Factory"
);
setup_unstable_lib(rosella, "assert", ["Core"],
"assert/Assert",
"assert/Debug",
"assert/Method",
"assert/Interface"
);
setup_unstable_lib(rosella, "lazy", ["Core", "Proxy"],
"lazy/Lazy",
"lazy/Builder",
"lazy/Controller",
"lazy/Factory"
);
setup_unstable_lib(rosella, "benchmark", ["Core", "Math_Builtins"],
"benchmark/Benchmark",
"benchmark/Result"
);
setup_unstable_lib(rosella, "repl", ["Core"],
"repl/Repl",
"repl/Commands",
"repl/CommandFuncs",
"repl/Compiler",
"repl/State",
"repl/View"
);
setup_unstable_lib(rosella, "genetic", ["Core", "Query", "Random"],
"genetic/Cell",
"genetic/Context",
"genetic/Engine",
"genetic/Mutator",
"genetic/mutator/Generic"
);
setup_unstable_lib(rosella, "feed", ["Core", "Xml", "Net", "FileSystem"],
"feed/Feed",
"feed/Entry",
"feed/Writer"
);
}
function setup_utilities(var rosella)
{
var utilities = {
"winxed_repl" : {
"install_name" : "winxed_repl",
"includes" : ["Core", "Repl"]
},
"test_all_lib" : {
"install_name" : "rosella_test_all_lib",
"includes" : ["Core", "FileSystem", "String", "Template", "CommandLine", "Query", "Reflect"]
},
"test_template" : {
"install_name" : "rosella_test_template",
"includes" : ["Core", "FileSystem", "Template", "CommandLine", "Query", "Reflect"]
},
"mk_winxed_header" : {
"install_name" : "winxed_mk_header",
"includes" : ["Core", "FileSystem", "CommandLine", "Query", "Reflect"]
},
"harness" : {
"install_name" : "rosella_harness",
"includes" : ["Core", "Harness"]
},
"parrot_release" : {
"install_name" : "parrot_release",
"includes" : ["Core", "FileSystem", "Template", "String", "Query", "Date"]
},
"templatecc" : {
"install_name" : "rosella_templatecc",
"includes" : ["Core", "CommandLine", "Template"]
},
"rosella_doc" : {
"install_name" : "rosella_doc",
"includes" : ["Core", "CommandLine", "FileSystem", "Query", "Reflect"]
}
};
string src_prefix = "src/utilities/";
string dest_prefix = "rosella/";
for (string util_source in utilities) {
string src_file = src_prefix + util_source + ".winxed";
string dest_file_base = string(utilities[util_source]["install_name"]);
string winxed_file = dest_prefix + dest_file_base + ".winxed";
string pir_file = dest_prefix + dest_file_base + ".pir";
string pbc_file = dest_prefix + dest_file_base + ".pbc";
var files = ["src/include/Builtins.winxed"];
var includes = utilities[util_source]["includes"];
for (string include in includes)
push(files, "src/include/" + include + ".winxed");
push(files, src_file);
rosella["winxed_winxed"][winxed_file] = files;
rosella["pir_winxed"][pir_file] = winxed_file;
rosella["pbc_pir"][pbc_file] = pir_file;
rosella["installable_pbc"][dest_file_base] = pbc_file;
}
}
function setup_data_files(var rosella)
{
rosella["inst_data"] = [
"rosella/data/templates/test_class.nqp.template",
"rosella/data/templates/test_class.winxed.template",
"rosella/data/templates/test_ns.winxed.template",
"rosella/data/templates/test_harness.nqp.template",
"rosella/data/templates/test_harness.winxed.template",
"rosella/data/templates/release_directions.template",
"rosella/data/templates/release.json.template",
"rosella/data/templates/release_announce.txt.template",
"rosella/data/templates/release_announce.html.template",
"rosella/data/templates/release_announce.md.template"
];
}
function setup_include_headers(var rosella)
{
rosella["inst_wxheader"] = {
"src/include/Action.winxed" : "Rosella/Action.winxed",
"src/include/Ascii.winxed" : "Rosella/Ascii.winxed",
"src/include/Builtins.winxed" : "Rosella/Builtins.winxed",
"src/include/CommandLine.winxed" : "Rosella/CommandLine.winxed",
"src/include/Container.winxed" : "Rosella/Container.winxed",
"src/include/Core.winxed" : "Rosella/Core.winxed",
"src/include/Dumper.winxed" : "Rosella/Dumper.winxed",
"src/include/Event.winxed" : "Rosella/Event.winxed",
"src/include/FileSystem.winxed" : "Rosella/FileSystem.winxed",
"src/include/Genetic.winxed" : "Rosella/Genetic.winxed",
"src/include/Harness.winxed" : "Rosella/Harness.winxed",
"src/include/Json.winxed" : "Rosella/Json.winxed",
"src/include/Math_Builtins.winxed" : "Rosella/Math_Builtins.winxed",
"src/include/Memoize.winxed" : "Rosella/Memoize.winxed",
"src/include/MockObject.winxed" : "Rosella/MockObject.winxed",
"src/include/Net.winxed" : "Rosella/Net.winxed",
"src/include/Parse.winxed" : "Rosella/Parse.winxed",
"src/include/Parse_builtins.winxed" : "Rosella/Parse_builtins.winxed",
"src/include/Proxy.winxed" : "Rosella/Proxy.winxed",
"src/include/Path.winxed" : "Rosella/Path.winxed",
"src/include/Query.winxed" : "Rosella/Query.winxed",
"src/include/Random.winxed" : "Rosella/Random.winxed",
"src/include/Repl.winxed" : "Rosella/Repl.winxed",
"src/include/String.winxed" : "Rosella/String.winxed",
"src/include/Template.winxed" : "Rosella/Template.winxed",
"src/include/Test.winxed" : "Rosella/Test.winxed",
"src/include/Winxed.winxed" : "Rosella/Winxed.winxed"
};
}
function setup_winxed_lib(var rosella, string name, var includes, var files [slurpy],
var named [slurpy,named])
{
setup_lib_internal(rosella, name, "src/", includes, files, named);
}
function setup_unstable_lib(var rosella, string name, var includes, var files [slurpy],
var named [slurpy,named])
{
setup_lib_internal(rosella, name, "src/unstable/", includes, files, named);
}
function setup_lib_internal(var rosella, string name, string prefix,
var includes, var files_raw, var named)
{
var pir_files = [];
setup_lib_constants(rosella, name, prefix, named);
// Get a list of all files
var files = ["src/include/Builtins.winxed"];
for (string include in includes)
push(files, "src/include/" + include + ".winxed");
for (string file in files_raw)
push(files, prefix + file + ".winxed");
string winxed_master = "rosella/" + name + ".winxed";
string pbc_lib_name = "rosella/" + name + ".pbc";
string pir_lib_name = "rosella/" + name + ".pir";
rosella["winxed_winxed"][winxed_master] = files;
rosella["pir_winxed"][pir_lib_name] = winxed_master;
rosella["pbc_pir"][pbc_lib_name] = pir_lib_name;
rosella["inst_lib"].push(pbc_lib_name);
rosella["manifest_includes"].push(pir_lib_name);
}
function setup_lib_constants(var rosella, string name, string prefix, var args)
{
var constants_files = args["constants"];
if (constants_files == null || elements(constants_files) == 0)
return;
for (string constant_file in constants_files) {
string pasm_file = sprintf("%s%s.pasm", [prefix, constant_file]);
string winxed_file = sprintf("%s%s.winxed", [prefix, constant_file]);
rosella["include_winxed"][pasm_file] = winxed_file;
}
}
// Load in the distutils library, which we are also responsible for
// building. If we don't have a version handy, load in the bootstrapping
// version. If we do have one built, use that instead
function setup_distutils()
{
#int e = 0;
#string distutils = "rosella/winxed.pbc";
#${ stat e, distutils, 0 };
#if (e)
# load_bytecode(distutils);
#else {
# say("Bootstrapping build with existing distutils library");
load_bytecode("src/winxed/Distutils.bootstrap.pir");
#}
using Rosella.Winxed.Distutils.winxed_setup;
winxed_setup();
using register_step_before;
using build_version_file;
using clean_version_file;
register_step_before("build", build_version_file);
register_step_before("clean", clean_version_file);
}
// TODO: "build" first, before we test.
function do_test()
{
using get_nqp;
string nqp = "parrot-nqp"; //get_nqp();
string cmd = nqp + " t/harness";
int result;
${ spawnw result, cmd };
return result;
}
function get_all_tests(var rosella, string path)
{
loadlib("os");
var os = new OS;
int STAT_ISREG = 0x8000;
int STAT_ISDIR = 0x4000;
var contents_raw = os.readdir(path);
for (string file in contents_raw) {
string entry = path + "/" + file;
var stat = os.stat(entry);
int mode = stat[2];
int isdir = 0;
${ band isdir, mode, STAT_ISDIR };
int isfile = 0;
${ band isfile, mode, STAT_ISREG };
if (file[0] == ".")
continue;
if (isfile == STAT_ISREG && is_test(entry))
rosella["manifest_includes"].push(entry);
if (isdir == STAT_ISDIR)
get_all_tests(rosella, entry);
}
}
function is_test(string path)
{
int len = length(path);
string ext = substr(path, len - 2);
if (ext == ".t")
return 1;
else
return 0;
}
function build_version_file(var rosella)
{
using newer;
using Rosella.Winxed.Distutils.make_path_for;
string file = "src/_build/_versions.winxed";
make_path_for(file);
int e = 0;
${ stat e, file, 0 };
if (!e || newer("VERSION", file))
build_and_compile_version_file(rosella);
}
function clean_version_file(var rosella)
{
string file = "src/_build/_versions.winxed";
using unlink;
int e = 0;
${ stat e, file, 0 };
if (e) {
say("unlink " + file);
unlink(file);
}
}
function build_and_compile_version_file(var rosella)
{
print("Reading version information...");
var verfile = new 'FileHandle';
verfile.open('VERSION', 'r');
string text = verfile.readall();
verfile.close();
var lines = split("\n", text);
var code = new 'StringBuilder';
string preamble = <<:
namespace Rosella { namespace __PRIVATE_Version
{
// This file is automatically generated by setup.winxed.
// DO NOT MODIFY THIS FILE YOURSELF
// Seriously, it's a bad idea.
function __GET_VERSION_HASH[anon]()
{
return {
:>>
;
push(code, preamble);
for (string line in lines) {
var parts = split(': ', line);
if (elements(parts) != 2)
continue;
string libname = parts[0];
parts = split(' ', parts[1]);
push(code, sprintf(" '%s' : new Rosella.Version('%s', %s, '%s'),\n", [libname, libname, parts[0], parts[1]]));
}
string postamble = <<:
"UNKNOWN" : new Rosella.Version('UNKNOWN', -1, 'UNKNOWN')
};
}
}}
:>>
;
push(code, postamble);
var file = new 'FileHandle';
file.open("src/_build/_versions.winxed", "w");
file.print(string(code));
file.close();
say("done.");
}
function main[main](var argv)
{
int exit_code = 0;
if (argv[1] == "test")
do_test();
else {
try {
setup_main(argv);
} catch (e) {
say(e["message"]);
for (string bt in e.backtrace_strings())
say(bt);
exit_code = 1;
}
}
if (exit_code != 0)
exit(exit_code);
}
Jump to Line
Something went wrong with that request. Please try again.