Compile first dependencies
This commit is contained in:
parent
05d891a0ee
commit
011defaff5
2 changed files with 19 additions and 11 deletions
|
@ -21,6 +21,7 @@ int main(string[] args)
|
||||||
|
|
||||||
string json = readText(dubFile);
|
string json = readText(dubFile);
|
||||||
JSONValue root = parseJSON(json);
|
JSONValue root = parseJSON(json);
|
||||||
|
string target = root["targetName"].str;
|
||||||
|
|
||||||
string cmake = q"<
|
string cmake = q"<
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
@ -46,31 +47,31 @@ if(APP_MAIN_FILE)
|
||||||
else(APP_MAIN_FILE)
|
else(APP_MAIN_FILE)
|
||||||
add_library(%1$s ${SRC_FILES})
|
add_library(%1$s ${SRC_FILES})
|
||||||
endif(APP_MAIN_FILE)
|
endif(APP_MAIN_FILE)
|
||||||
>".format(root["targetName"].str);
|
>".format(target);
|
||||||
break;
|
break;
|
||||||
case "none":
|
case "none":
|
||||||
break;
|
break;
|
||||||
case "executable":
|
case "executable":
|
||||||
cmake ~= q"<
|
cmake ~= q"<
|
||||||
add_executable(%s ${SRC_FILES} ${APP_MAIN_FILE})
|
add_executable(%s ${SRC_FILES} ${APP_MAIN_FILE})
|
||||||
>".format(root["targetName"].str);
|
>".format(target);
|
||||||
break;
|
break;
|
||||||
case "library":
|
case "library":
|
||||||
cmake ~= q"<
|
cmake ~= q"<
|
||||||
add_library(%s ${SRC_FILES})
|
add_library(%s ${SRC_FILES})
|
||||||
>".format(root["targetName"].str);
|
>".format(target);
|
||||||
break;
|
break;
|
||||||
case "sourceLibrary":
|
case "sourceLibrary":
|
||||||
break;
|
break;
|
||||||
case "staticLibrary":
|
case "staticLibrary":
|
||||||
cmake ~= q"<
|
cmake ~= q"<
|
||||||
add_library(%s STATIC ${SRC_FILES})
|
add_library(%s STATIC ${SRC_FILES})
|
||||||
>".format(root["targetName"].str);
|
>".format(target);
|
||||||
break;
|
break;
|
||||||
case "dynamicLibrary":
|
case "dynamicLibrary":
|
||||||
cmake ~= q"<
|
cmake ~= q"<
|
||||||
add_library(%s SHARED ${SRC_FILES})
|
add_library(%s SHARED ${SRC_FILES})
|
||||||
>".format(root["targetName"].str);
|
>".format(target);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false, "Unknown targetType");
|
assert(false, "Unknown targetType");
|
||||||
|
@ -84,9 +85,9 @@ add_library(%s SHARED ${SRC_FILES})
|
||||||
{
|
{
|
||||||
cmake ~= "DubProject_Add(%s %s)\n".format(dependency, version_.str);
|
cmake ~= "DubProject_Add(%s %s)\n".format(dependency, version_.str);
|
||||||
}
|
}
|
||||||
|
cmake ~= "\nadd_dependencies(%s %-(%s %))\n".format(target, root["dependencies"].object.keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std.file.write(cmakeFile, cmake);
|
std.file.write(cmakeFile, cmake);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -94,24 +94,31 @@ int main(string[] args)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stderr.writefln("No version tagged '%s' found.", packageVersion);
|
stderr.writefln("%s has no version tagged %s.", root["name"].str, packageVersion);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto nodes = root["versions"].array.filter!(a => SemVer(a["version"].str).valid).array;
|
string nodeVersionString(JSONValue node)
|
||||||
auto maxVersion = nodes.map!(a => SemVer(a["version"].str)).array.maxSatisfying(versionRange);
|
{
|
||||||
|
auto ver = node["version"].str;
|
||||||
|
ver.skipOver('~');
|
||||||
|
return ver;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto nodes = root["versions"].array.filter!(a => SemVer(nodeVersionString(a)).valid).array;
|
||||||
|
auto maxVersion = nodes.map!(a => SemVer(nodeVersionString(a))).array.maxSatisfying(versionRange);
|
||||||
|
|
||||||
if (maxVersion.valid)
|
if (maxVersion.valid)
|
||||||
{
|
{
|
||||||
auto range = nodes.find!((a, b) => SemVer(a["version"].str) == b)(maxVersion);
|
auto range = nodes.find!((a, b) => SemVer(nodeVersionString(a)) == b)(maxVersion);
|
||||||
assert(!range.empty);
|
assert(!range.empty);
|
||||||
node = range[0];
|
node = range[0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stderr.writefln("No version '%s' found.", versionRange);
|
stderr.writefln("%s has no version %s.", root["name"].str, versionRange);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue