123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- module backporter.builder;
-
- import backporter.git;
- import backporter.core;
- import std.stdio : File;
- import std.experimental.logger;
- import std.file;
- import std.path;
-
- bool checkout(PackageRevision pkg, string dir)
- {
- if (!dir.exists || !chainPath(dir, ".git").exists)
- {
- auto parent = dirName(dir);
- mkdirRecurse(parent);
- cd(parent);
- if (clone(pkg.gitUrl, pkg.packageName).status != 0) return false;
- }
- cd(dir);
- return reset("--hard", pkg.commitId).status == 0;
- }
-
- Build build(Config config, PackageRevision revision)
- {
- Build result;
- result.revisionId = revision.revisionId;
- result.packageName = revision.packageName;
- result.compilerRelease = config.compilerRelease;
- static import datefmt;
- import std.datetime.systime : Clock;
- result.time = datefmt.format(Clock.currTime, datefmt.ISO8601FORMAT);
-
- auto dir = config.dataDir.buildPath(revision.packageName);
- if (!checkout(revision, dir)) return result;
- result.canCheckOut = true;
-
- cd(dir);
-
- // `dub build` includes app.d / main.d.
- // `dub test` runs unittests.
- // Without both, you can't be certain a package works.
- // `dub test` isn't quite enough, and this doesn't get subpackages...but this is okay for
- // starting out, at least.
- auto buildResult = run(
- config.buildTimeout,
- config.dubLoc,
- "build",
- "--compiler=" ~ config.dmdLoc
- );
- if (buildResult.status == 0)
- {
- result.canBuild = true;
- }
- auto testResult = run(
- config.buildTimeout,
- config.dubLoc,
- "test",
- "--compiler=" ~ config.dmdLoc
- );
- if (testResult.status == 0)
- {
- result.canTest = true;
- }
- import std.string : representation;
- import std.algorithm.searching : canFind;
- result.hasDeprecations = buildResult.stderr.canFind("Deprecated".representation);
- return result;
- }
-
- void buildAll(Config config, PackageRevision[] pkgs)
- {
- foreach (pkg; pkgs)
- {
- auto res = build(config, pkg);
- config.record(res);
- /*
- config.outfile.writefln("%s,%s,%s,%s,%s,%s,%s",
- config.compilerRelease,
- res.revision.pkg.name,
- res.revision.id,
- res.canCheckOut,
- res.canBuild,
- res.canTest,
- res.hasDeprecations);
- config.outfile.flush;
- */
- }
- }
-
- void exerciseRelease(Config config, string compilerRelease)
- {
- import backporter.dmd;
- config.compilerRelease = compilerRelease;
- downloadCompiler(config);
- auto remaining = config.countRemainingPackages(compilerRelease);
- while (true)
- {
- auto pkg = config.nextPackage(config.compilerRelease);
- if (pkg == PackageRevision.init)
- {
- break;
- }
- infof("dmd %s package %s.%s (%s remaining)",
- config.compilerRelease,
- pkg.packageName,
- pkg.revisionId,
- remaining);
- remaining--;
- config.record(build(config, pkg));
- }
- }
|