Skip to content

Commit

Permalink
Merge pull request #1098 from MartinNowak/merge_master
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'upstream/master' into merge_master
  • Loading branch information
MartinNowak authored Mar 22, 2017
2 parents 26bee1b + 36b1464 commit 26117b7
Show file tree
Hide file tree
Showing 48 changed files with 490 additions and 449 deletions.
17 changes: 17 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Documentation: https://docs.codecov.io/docs/codecov-yaml

codecov:
bot: dlang-bot

coverage:
precision: 3
# round: down
# range: "70...100"

status:
# Learn more at https://docs.codecov.io/docs/commit-status
project: true
patch: true
changes: false

comment: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ __dummy.html
/bin/dub
/bin/__test__library-nonet__
/bin/__test__library__
/bin/dub-test-library

# Ignore files or directories created by the test suite.
/test/custom-source-main-bug487/custom-source-main-bug487
Expand Down
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ sudo: false

matrix:
include:
- d: dmd-2.072.0-b2
env: [FRONTEND=2.072]
- d: dmd-2.071.2
- d: dmd-2.073.0
env:
- [FRONTEND=2.071]
- [FRONTEND=2.073]
- [COVERAGE=true]
- d: dmd-2.072.2
env: [FRONTEND=2.072]
- d: dmd-2.071.2
env: [FRONTEND=2.071]
- d: dmd-2.070.2
env: [FRONTEND=2.070]
- d: dmd-2.069.2
Expand All @@ -21,7 +23,7 @@ matrix:
env: [FRONTEND=2.066]
- d: dmd-2.065.0
env: [FRONTEND=2.065]
- d: ldc-1.1.0-beta6
- d: ldc-1.1.0
env: [FRONTEND=2.071]
- d: ldc-1.0.0
env: [FRONTEND=2.070]
Expand All @@ -39,8 +41,6 @@ matrix:
env: [FRONTEND=2.066]
- d: gdc-4.9.0
env: [FRONTEND=2.065]
allow_failures:
- d: ldc-1.1.0-beta6

script:
- ./travis-ci.sh
12 changes: 6 additions & 6 deletions source/dub/compilers/buildsettings.d
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ struct BuildSettings {
// add string import files (avoids file name duplicates in addition to path duplicates)
private void addSI(ref string[] arr, in string[] vals)
{
outer:
bool[string] existing;
foreach (v; arr) existing[Path(v).head.toString()] = true;
foreach (v; vals) {
auto vh = Path(v).head;
foreach (ve; arr) {
if (Path(ve).head == vh)
continue outer;
auto s = Path(v).head.toString();
if (s !in existing) {
existing[s] = true;
arr ~= v;
}
arr ~= v;
}
}

Expand Down
3 changes: 3 additions & 0 deletions source/dub/dependency.d
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ struct PackageDependency {
package name is notably not part of the dependency specification.
*/
struct Dependency {
@trusted: // Too many issues on DMD 2.065.0 to annotate with @safe

private {
// Shortcut to create >=0.0.0
enum ANY_IDENT = "*";
Expand Down Expand Up @@ -632,6 +634,7 @@ unittest {
Semantic Versioning Specification v2.0.0 at http://semver.org/).
*/
struct Version {
@safe:
private {
enum MAX_VERS = "99999.0.0";
enum UNKNOWN_VERS = "unknown";
Expand Down
2 changes: 1 addition & 1 deletion source/dub/description.d
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct ProjectDescription {
PackageDescription[] packages; /// All packages in the dependency tree
TargetDescription[] targets; /// Build targets
@ignore size_t[string] targetLookup; /// Target index by package name name

/// Targets by name
ref inout(TargetDescription) lookupTarget(string name) inout
{
Expand Down
6 changes: 3 additions & 3 deletions source/dub/dub.d
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class Dub {
loading a package.
This constructor corresponds to the "--bare" option of the command line
interface. Use
interface. Use
*/
this(Path override_path)
{
Expand Down Expand Up @@ -243,7 +243,7 @@ class Dub {
Single-file packages are D files that contain a package receipe comment
at their top. A recipe comment must be a nested `/+ ... +/` style
comment, containing the virtual recipe file name and a colon, followed by the
comment, containing the virtual recipe file name and a colon, followed by the
recipe contents (what would normally be in dub.sdl/dub.json).
Example:
Expand Down Expand Up @@ -736,7 +736,7 @@ class Dub {
logInfo("Removing %s in %s", pack.name, pack.path.toNativeString());
if (!m_dryRun) m_packageManager.remove(pack);
}

/// Compatibility overload. Use the version without a `force_remove` argument instead.
void remove(in Package pack, bool force_remove)
{
Expand Down
2 changes: 1 addition & 1 deletion source/dub/generators/build.d
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class BuildGenerator : ProjectGenerator {
foreach (p; packages)
allfiles ~= (p.recipePath != Path.init ? p : p.basePackage).recipePath.toNativeString();
foreach (f; additional_dep_files) allfiles ~= f.toNativeString();
if (main_pack is m_project.rootPackage)
if (main_pack is m_project.rootPackage && m_project.rootPackage.getAllDependencies().length > 0)
allfiles ~= (main_pack.path ~ SelectedVersions.defaultFile).toNativeString();

foreach (file; allfiles.data) {
Expand Down
38 changes: 19 additions & 19 deletions source/dub/generators/cmake.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,71 +26,71 @@ class CMakeGenerator: ProjectGenerator
{
super(project);
}

override void generateTargets(GeneratorSettings settings, in TargetInfo[string] targets)
{
auto script = appender!(char[]);
auto scripts = appender!(string[]);
bool[string] visited;
Path projectRoot = m_project.rootPackage.path;
Path cmakeListsPath = projectRoot ~ "CMakeLists.txt";

foreach(name, info; targets)
{
if(visited.get(name, false))
continue;

visited[name] = true;
name = name.sanitize;
string targetType;
string libType;
bool addTarget = true;

switch(info.buildSettings.targetType) with(TargetType)
{
case autodetect:
throw new Exception("Don't know what to do about autodetect target type");
case executable:
targetType = "executable";

break;
case dynamicLibrary:
libType = "SHARED";

goto case;
case library:
case staticLibrary:
targetType = "library";

break;
case sourceLibrary:
addTarget = false;

break;
case none:
continue;
default:
assert(false);
}

script.put("include(UseD)\n");
script.put(
"add_d_conditions(VERSION %s DEBUG %s)\n".format(
info.buildSettings.versions.dup.join(" "),
info.buildSettings.debugVersions.dup.join(" "),
)
);

foreach(directory; info.buildSettings.importPaths)
script.put("include_directories(%s)\n".format(directory.sanitizeSlashes));

if(addTarget)
{
script.put("add_%s(%s %s\n".format(targetType, name, libType));

foreach(file; info.buildSettings.sourceFiles)
script.put(" %s\n".format(file.sanitizeSlashes));

script.put(")\n");
script.put(
"target_link_libraries(%s %s %s)\n".format(
Expand All @@ -106,29 +106,29 @@ class CMakeGenerator: ProjectGenerator
) ~ "\n"
);
}

string filename = (projectRoot ~ "%s.cmake".format(name)).toNativeString;
File file = File(filename, "w");

file.write(script.data);
file.close;
script.shrinkTo(0);
scripts.put(filename);
}

if(!cmakeListsPath.existsFile)
{
logWarn("You must use a fork of CMake which has D support for these scripts to function properly.");
logWarn("It is available at https://github.com/trentforkert/cmake");
logInfo("Generating default CMakeLists.txt");
script.put("cmake_minimum_required(VERSION 3.0)\n");
script.put("project(%s D)\n".format(m_project.rootPackage.name));

foreach(path; scripts.data)
script.put("include(%s)\n".format(path));

File file = File(cmakeListsPath.toNativeString, "w");

file.write(script.data);
file.close;
}
Expand Down
7 changes: 3 additions & 4 deletions source/dub/generators/generator.d
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ struct GeneratorSettings {
bool combined; // compile all in one go instead of each dependency separately

// only used for generator "build"
bool run, force, direct, clean, rdmd, tempBuild, parallelBuild;
bool run, force, direct, rdmd, tempBuild, parallelBuild;
string[] runArgs;
void delegate(int status, string output) compileCallback;
void delegate(int status, string output) linkCallback;
Expand Down Expand Up @@ -363,7 +363,7 @@ private void finalizeGeneration(in Package pack, in Project proj, in GeneratorSe
in BuildSettings buildsettings, Path target_path, bool generate_binary)
{
import std.path : globMatch;

if (buildsettings.postGenerateCommands.length && !isRecursiveInvocation(pack.name)) {
logInfo("Running post-generate commands for %s...", pack.name);
runBuildCommands(buildsettings.postGenerateCommands, pack, proj, settings, buildsettings);
Expand Down Expand Up @@ -508,13 +508,12 @@ void runBuildCommands(in string[] commands, in Package pack, in Project proj,
env["DUB_RUN"] = settings.run? "TRUE" : "";
env["DUB_FORCE"] = settings.force? "TRUE" : "";
env["DUB_DIRECT"] = settings.direct? "TRUE" : "";
env["DUB_CLEAN"] = settings.clean? "TRUE" : "";
env["DUB_RDMD"] = settings.rdmd? "TRUE" : "";
env["DUB_TEMP_BUILD"] = settings.tempBuild? "TRUE" : "";
env["DUB_PARALLEL_BUILD"] = settings.parallelBuild? "TRUE" : "";

env["DUB_RUN_ARGS"] = (cast(string[])settings.runArgs).map!(escapeShellFileName).join(" ");

auto depNames = proj.dependencies.map!((a) => a.name).array();
storeRecursiveInvokations(env, proj.rootPackage.name ~ depNames);
runCommands(commands, env);
Expand Down
4 changes: 2 additions & 2 deletions source/dub/generators/sublimetext.d
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SublimeTextGenerator : ProjectGenerator {
{
auto buildSettings = targets[m_project.name].buildSettings;
logDebug("About to generate sublime project for %s.", m_project.rootPackage.name);

auto root = Json([
"folders": targets.byValue.map!(f => targetFolderJson(f)).array.Json,
"build_systems": buildSystems(settings.platform),
Expand Down Expand Up @@ -100,7 +100,7 @@ private Json buildSystems(BuildPlatform buildPlatform, string workingDiretory =
"variants": [
[
"name": "Run".Json,
"cmd": ["dub", "run", "--build=" ~ buildType, "--arch=" ~ arch, "--compiler="~buildPlatform.compilerBinary].map!Json.array.Json,
"cmd": ["dub", "run", "--build=" ~ buildType, "--arch=" ~ arch, "--compiler="~buildPlatform.compilerBinary].map!Json.array.Json,
].Json
].array.Json,
]);
Expand Down
3 changes: 2 additions & 1 deletion source/dub/generators/visuald.d
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ class VisualDGenerator : ProjectGenerator {
//case compileOnly: singlefilemode = 3; break;
}
ret.formattedWrite(" <singleFileCompilation>%s</singleFileCompilation>\n", singlefilemode);
ret.formattedWrite(" <mscoff>%s</mscoff>", buildsettings.dflags.canFind("-m32mscoff") ? "1" : "0");
ret.put(" <oneobj>0</oneobj>\n");
ret.put(" <trace>0</trace>\n");
ret.put(" <quiet>0</quiet>\n");
Expand Down Expand Up @@ -524,7 +525,7 @@ private @property string vsArchitecture(string architecture)
{
switch(architecture) {
default: logWarn("Unsupported platform('%s'), defaulting to x86", architecture); goto case;
case "x86": return "Win32";
case "x86", "x86_mscoff": return "Win32";
case "x86_64": return "x64";
}
}
Loading

0 comments on commit 26117b7

Please sign in to comment.