Redesign of dlang.org

Rikki Cattermole via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 24 08:53:12 PDT 2014


On Thursday, 24 April 2014 at 14:42:44 UTC, Adam D. Ruppe wrote:
> On Thursday, 24 April 2014 at 03:59:00 UTC, Rikki Cattermole 
> wrote:
>> Can we have it as a library?
>
> css.d in there has the lib code now with my other html stuff 
> stripped out so it has fewer dependencies. Can dub just use it 
> without using the little main file?
Ugh it can yes. But when you set the target type it definitely 
cannot.

You probably want a dub.json file like this:

{
	"name": "cssexpand",
	"description": "A CSS expansion program",
	"authors": ["Adam D. Ruppe"],
	"homepage": "https://github.com/adamdruppe/cssexpand",
	"license": "BSL-1.0",
	"dependencies": {
		"cssexpand:library": "~master"
	},
	"subPackages": [
		{
			"name": "tool",
			"dependencies": {
				"cssexpand:library": "~master"
			},
			"mainSourceFile": "src/cssexpand.d",
			"targetType": "executable"
		},
		{
			"name": "library",
			"sourceFiles": ["src/css.d", "src/color.d"],
			"targetType": "library"
		}
	]
}

Defaults a library. To run the tool its basically:
dub run cssexpand:tool toolargs...
Or you can swap them, up to you.

> Note btw that this code is *brutally* slow and should be done 
> ahead of time or at least aggressively cached; if you 
> regenerate the file on each request you'll be surprised by how 
> much cpu time it wastes.
Lets not go into how much javascript code I'm generating in Cmsed 
;) So not a worry.

> The implementation is pretty much a brute force string search 
> in a replace loop.



More information about the Digitalmars-d mailing list