Browse Source

[dlang] upgrade dlang compilers to the latest version (#3213)

* [Dlang/vibed] use mir.random for faster random number generation

* [dlang] upgrade dlang compilers to the latest version

* [dlang/hunt.collie] update to latest version

* [dlang/hunt.collie] fix compilation
Daniel Kozak 7 years ago
parent
commit
4b8bc378ed

+ 1 - 1
frameworks/D/collie/dub.json

@@ -5,6 +5,6 @@
 	"authors": ["dsby"],
 	"authors": ["dsby"],
 	"targetType": "executable",
 	"targetType": "executable",
 	"dependencies": {
 	"dependencies": {
-            "collie" : "~>0.9.6"
+            "collie" : "~>0.10.3"
 	}
 	}
 }
 }

+ 1 - 0
frameworks/D/collie/setup.sh

@@ -7,6 +7,7 @@ rm -f http
 rm -rf .dub
 rm -rf .dub
 rm -f dub.selections.json
 rm -f dub.selections.json
 
 
+dub upgrade --verbose
 dub build -f -b release
 dub build -f -b release
 
 
 ./http &
 ./http &

+ 1 - 0
frameworks/D/collie/setup_ldc.sh

@@ -7,6 +7,7 @@ rm -f http
 rm -rf .dub
 rm -rf .dub
 rm -f dub.selections.json
 rm -f dub.selections.json
 
 
+dub upgrade --verbose
 dub build -f -b release --compiler=ldc2
 dub build -f -b release --compiler=ldc2
 
 
 ./http &
 ./http &

+ 2 - 2
frameworks/D/collie/source/app.d

@@ -15,7 +15,7 @@ import std.typecons;
 import std.functional;
 import std.functional;
 import std.parallelism;
 import std.parallelism;
 
 
-import collie.socket;
+import collie.net;
 import collie.codec.http;
 import collie.codec.http;
 import collie.codec.http.server;
 import collie.codec.http.server;
 
 
@@ -42,7 +42,7 @@ void main()
     writeln("Edit source/app.d to start your project.");
     writeln("Edit source/app.d to start your project.");
     globalLogLevel(LogLevel.warning);
     globalLogLevel(LogLevel.warning);
     HTTPServerOptions option = new HTTPServerOptions();
     HTTPServerOptions option = new HTTPServerOptions();
-    option.handlerFactories.insertBack(&newHandler);
+    option.handlerFactories ~= toDelegate(&newHandler);
     option.threads = totalCPUs;
     option.threads = totalCPUs;
     HttpServer server = new HttpServer(option);
     HttpServer server = new HttpServer(option);
 
 

+ 1 - 2
frameworks/D/collie/source/get.d

@@ -2,11 +2,10 @@
 
 
 import collie.codec.http;
 import collie.codec.http;
 import collie.codec.http.server;
 import collie.codec.http.server;
-import collie.utils.vector;
 import std.json;
 import std.json;
 import std.typecons;
 import std.typecons;
 import std.exception;
 import std.exception;
-
+import kiss.container.Vector;
 import request;
 import request;
 
 
 final class GetHandler : BaseHandler
 final class GetHandler : BaseHandler

+ 1 - 1
frameworks/D/collie/source/post.d

@@ -3,11 +3,11 @@
 
 
 import collie.codec.http;
 import collie.codec.http;
 import collie.codec.http.server;
 import collie.codec.http.server;
-import collie.utils.vector;
 import request;
 import request;
 import std.json;
 import std.json;
 import std.typecons;
 import std.typecons;
 import std.exception;
 import std.exception;
+import kiss.container.Vector;
 
 
 final class PostHandler : BaseHandler
 final class PostHandler : BaseHandler
 {
 {

+ 1 - 1
frameworks/D/collie/source/request.d

@@ -2,11 +2,11 @@ module request;
 
 
 import collie.codec.http;
 import collie.codec.http;
 import collie.codec.http.server;
 import collie.codec.http.server;
-import collie.utils.vector;
 import std.exception;
 import std.exception;
 import std.datetime;
 import std.datetime;
 import std.conv;
 import std.conv;
 import std.string;
 import std.string;
+import kiss.container.Vector;
 
 
 abstract class BaseHandler : RequestHandler
 abstract class BaseHandler : RequestHandler
 {
 {

+ 0 - 1
frameworks/D/hunt/config/application.conf

@@ -7,7 +7,6 @@ application.secret=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 application.encoding=UTF-8
 application.encoding=UTF-8
 
 
 session.prefix=hunt
 session.prefix=hunt
-session.storage=memcache
 session.expire=3600
 session.expire=3600
 
 
 http.address=0.0.0.0
 http.address=0.0.0.0

+ 3 - 3
frameworks/D/hunt/dub.json

@@ -4,10 +4,10 @@
 	"copyright": "Copyright © 2016, huntframework.com",
 	"copyright": "Copyright © 2016, huntframework.com",
 	"targetType": "executable",
 	"targetType": "executable",
 	"stringImportPaths": [
 	"stringImportPaths": [
-		"./resources/views",
+		"./resources/views"
 	],
 	],
 	"mainSourceFile": "./source/bootstrap.d",
 	"mainSourceFile": "./source/bootstrap.d",
 	"dependencies": {
 	"dependencies": {
-		"hunt": "0.6.2"
-	},
+		"hunt": "0.10.4"
+	}
 }
 }

+ 2 - 0
frameworks/D/hunt/setup.sh

@@ -7,6 +7,8 @@ rm -f website
 rm -rf .dub
 rm -rf .dub
 rm -f dub.selections.json
 rm -f dub.selections.json
 
 
+dub upgrade --verbose
+
 dub build -f -b release -v
 dub build -f -b release -v
 
 
 ./website
 ./website

+ 3 - 2
frameworks/D/vibed/dub.json

@@ -8,7 +8,8 @@
   ],
   ],
   "dependencies": {
   "dependencies": {
     "vibe-d": "0.8.2",
     "vibe-d": "0.8.2",
-    "vibe-core": "1.3.0"
+    "vibe-core": "1.3.0",
+    "mir-random": "0.3.2"
   },
   },
   "targetType": "executable",
   "targetType": "executable",
   "sourcePaths": [],
   "sourcePaths": [],
@@ -24,4 +25,4 @@
       "mainSourceFile": "source/mongodb.d"
       "mainSourceFile": "source/mongodb.d"
     }
     }
   ]
   ]
-}
+}

+ 14 - 6
frameworks/D/vibed/source/mongodb.d

@@ -4,8 +4,11 @@ import vibe.http.router;
 import vibe.http.server;
 import vibe.http.server;
 import vibe.web.web;
 import vibe.web.web;
 
 
+import mir.random : unpredictableSeedOf;
+import mir.random.variable : UniformVariable;
+import mir.random.engine.xorshift : Xorshift;
+
 import std.conv : ConvException, to;
 import std.conv : ConvException, to;
-import std.random : uniform;
 import std.array;
 import std.array;
 
 
 enum worldSize = 10000;
 enum worldSize = 10000;
@@ -33,6 +36,8 @@ class WebInterface {
 	private {
 	private {
 		MongoCollection _worldCollection;
 		MongoCollection _worldCollection;
 		MongoCollection _fortuneCollection;
 		MongoCollection _fortuneCollection;
+		UniformVariable!uint _uniformVariable;
+		Xorshift _gen;
 	}
 	}
 
 
 	this()
 	this()
@@ -41,6 +46,9 @@ class WebInterface {
 		auto db = connectMongoDB(environment.get("DBHOST", "127.0.0.1"));
 		auto db = connectMongoDB(environment.get("DBHOST", "127.0.0.1"));
 		_worldCollection = db.getCollection("hello_world.world");
 		_worldCollection = db.getCollection("hello_world.world");
 		_fortuneCollection = db.getCollection("hello_world.fortune");
 		_fortuneCollection = db.getCollection("hello_world.fortune");
+
+		_gen = Xorshift(unpredictableSeedOf!uint);
+		_uniformVariable = UniformVariable!uint(1, worldSize);
 	}
 	}
 
 
 	// GET /
 	// GET /
@@ -61,7 +69,7 @@ class WebInterface {
 	void getDB(HTTPServerResponse res)
 	void getDB(HTTPServerResponse res)
 	{
 	{
 		struct Q { int _id; }
 		struct Q { int _id; }
-		auto query = Q(uniform(1, worldSize + 1));
+		auto query = Q(_uniformVariable(_gen));
 		auto w = WorldResponse(_worldCollection.findOne!World(query));
 		auto w = WorldResponse(_worldCollection.findOne!World(query));
 		res.writeJsonBody(w, HTTPStatus.ok, "application/json");
 		res.writeJsonBody(w, HTTPStatus.ok, "application/json");
 	}
 	}
@@ -78,11 +86,11 @@ class WebInterface {
 		try count = min(max(queries.to!int, 1), 500);
 		try count = min(max(queries.to!int, 1), 500);
 		catch (ConvException) {}
 		catch (ConvException) {}
 
 
-		// assemble the response array    
+		// assemble the response array
 		scope data = new WorldResponse[count];
 		scope data = new WorldResponse[count];
 		foreach (ref w; data) {
 		foreach (ref w; data) {
 			static struct Q { int _id; }
 			static struct Q { int _id; }
-			auto query = Q(uniform(1, worldSize + 1));
+			auto query = Q(_uniformVariable(_gen));
 			w = WorldResponse(_worldCollection.findOne!World(query));
 			w = WorldResponse(_worldCollection.findOne!World(query));
 		}
 		}
 
 
@@ -114,11 +122,11 @@ class WebInterface {
 		scope data = new WorldResponse[count];
 		scope data = new WorldResponse[count];
 		foreach (ref w; data) {
 		foreach (ref w; data) {
 			static struct Q { int _id; }
 			static struct Q { int _id; }
-			auto query = Q(uniform(1, worldSize + 1));
+			auto query = Q(_uniformVariable(_gen));
 			w = WorldResponse(_worldCollection.findOne!World(query));
 			w = WorldResponse(_worldCollection.findOne!World(query));
 
 
 			// update random number
 			// update random number
-			w.randomNumber = uniform(1, worldSize+1);
+			w.randomNumber = _uniformVariable(_gen);
 
 
 			// persist to DB
 			// persist to DB
 			static struct US {
 			static struct US {

+ 2 - 2
toolset/setup/linux/languages/dlang.sh

@@ -5,8 +5,8 @@ fw_depends xdg-utils
 fw_installed dlang && return 0
 fw_installed dlang && return 0
 
 
 DLANG=$IROOT/dlang
 DLANG=$IROOT/dlang
-DMDVER="2.077.0"
-LDCVER="1.5.0"
+DMDVER="2.078.1"
+LDCVER="1.7.0"
 
 
 mkdir -p $DLANG
 mkdir -p $DLANG
 fw_get -O http://downloads.dlang.org/releases/2.x/$DMDVER/dmd_$DMDVER-0_amd64.deb
 fw_get -O http://downloads.dlang.org/releases/2.x/$DMDVER/dmd_$DMDVER-0_amd64.deb