mirror of
https://github.com/dlang/phobos.git
synced 2025-05-03 08:30:33 +03:00
Remove Phobos 3 dub.sdl and replace it with the build_v3.d build script. (#9069)
* Remove Phobos 3 dub.sdl and replace it with the build_v3.d buid script. * Add environment bang to the build script. * Fix the Phobos v3 build script so that unit tests work on POSIX. --------- Co-authored-by: Jonathan M Davis <jmdavis@jmdavisprog.com>
This commit is contained in:
parent
03c4998e85
commit
2852e84aa9
3 changed files with 147 additions and 20 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -27,3 +27,10 @@ libphobos_*
|
||||||
source/
|
source/
|
||||||
|
|
||||||
tools/ucd*
|
tools/ucd*
|
||||||
|
|
||||||
|
# Build specific exclusions
|
||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
*.obj
|
||||||
|
*.exe
|
||||||
|
unittest
|
140
build_v3.d
Executable file
140
build_v3.d
Executable file
|
@ -0,0 +1,140 @@
|
||||||
|
#!/usr/bin/env rdmd
|
||||||
|
/**
|
||||||
|
Phobos V3 Build Script
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
./build_v3.d [debug,release,unittest]
|
||||||
|
*/
|
||||||
|
|
||||||
|
import std.conv;
|
||||||
|
import std.datetime;
|
||||||
|
import std.file;
|
||||||
|
import std.path;
|
||||||
|
import std.process;
|
||||||
|
import std.stdio;
|
||||||
|
import std.string;
|
||||||
|
|
||||||
|
int main(string[] args)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
bool buildUnittest = false;
|
||||||
|
bool buildRelease = false;
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
buildUnittest = args[1] == "unittest";
|
||||||
|
buildRelease = args[1] == "release";
|
||||||
|
}
|
||||||
|
|
||||||
|
string argFilePath = buildNormalizedPath(getcwd(), "phobosbuildargs.txt");
|
||||||
|
auto dFiles = dirEntries(buildNormalizedPath(getcwd(), "phobos"), "*.d", SpanMode.breadth);
|
||||||
|
auto argFile = File(argFilePath, "w");
|
||||||
|
|
||||||
|
version(Windows)
|
||||||
|
{
|
||||||
|
string unittestExecutable = buildNormalizedPath(getcwd(), "unittest.exe");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string unittestExecutable = buildNormalizedPath(getcwd(), "unittest");
|
||||||
|
}
|
||||||
|
|
||||||
|
scope(exit)
|
||||||
|
{
|
||||||
|
argFile.close();
|
||||||
|
remove(argFilePath);
|
||||||
|
|
||||||
|
if (exists(unittestExecutable)) remove(unittestExecutable);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = runCommand("dmd --version", getcwd());
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
|
writeln("Compiler Failure.");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
writeln("Source files:");
|
||||||
|
//Add source file list to args file.
|
||||||
|
foreach(dFile; dFiles)
|
||||||
|
{
|
||||||
|
if (dFile.isDir()) continue;
|
||||||
|
argFile.writeln(dFile.name);
|
||||||
|
writeln(dFile.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add appropriate DMD arguments to the args file.
|
||||||
|
argFile.writeln("-od=./lib");
|
||||||
|
if (buildUnittest)
|
||||||
|
{
|
||||||
|
argFile.writeln("-main");
|
||||||
|
argFile.writeln("-unittest");
|
||||||
|
argFile.writeln("-debug");
|
||||||
|
|
||||||
|
version(Windows)
|
||||||
|
{
|
||||||
|
argFile.writeln("-of=unittest.exe");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
argFile.writeln("-of=unittest");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (buildRelease)
|
||||||
|
{
|
||||||
|
argFile.writeln("-release -O");
|
||||||
|
argFile.writeln("-lib");
|
||||||
|
argFile.writeln("-of=libphobos3");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
argFile.writeln("-debug");
|
||||||
|
argFile.writeln("-lib");
|
||||||
|
argFile.writeln("-of=libphobos3-debug");
|
||||||
|
}
|
||||||
|
|
||||||
|
argFile.flush();
|
||||||
|
argFile.close();
|
||||||
|
|
||||||
|
//Run the build.
|
||||||
|
result = runCommand("dmd @\"" ~ argFilePath ~ "\"", getcwd());
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
|
writeln("Build failed.");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeln("Build successful.");
|
||||||
|
writeln();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Run unittests if built.
|
||||||
|
if (buildUnittest)
|
||||||
|
{
|
||||||
|
writeln("Running tests...");
|
||||||
|
result = runCommand(unittestExecutable, getcwd());
|
||||||
|
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
|
writeln("Tests failed.");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeln("Tests successful.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int runCommand(string command, string workDir)
|
||||||
|
{
|
||||||
|
auto pid = pipeShell(command, Redirect.all, null, Config.none, workDir);
|
||||||
|
int result = wait(pid.pid);
|
||||||
|
foreach (line; pid.stdout.byLine) writeln(line);
|
||||||
|
foreach (line; pid.stderr.byLine) writeln(line);
|
||||||
|
writeln();
|
||||||
|
return result;
|
||||||
|
}
|
20
dub.sdl
20
dub.sdl
|
@ -1,20 +0,0 @@
|
||||||
name "phobos"
|
|
||||||
license "BSL-1.0"
|
|
||||||
description "D Standard Library"
|
|
||||||
authors "DLang Community"
|
|
||||||
copyright "Copyright © 1999-2024, The D Language Foundation"
|
|
||||||
|
|
||||||
configuration "library" {
|
|
||||||
targetType "staticLibrary"
|
|
||||||
sourcePaths "phobos"
|
|
||||||
targetPath "generated-lib"
|
|
||||||
#excludedSourceFiles "unittest.d" "test/**" "std/**" "tools/**" "etc/**"
|
|
||||||
}
|
|
||||||
|
|
||||||
configuration "unittest" {
|
|
||||||
dflags "-main"
|
|
||||||
targetType "executable"
|
|
||||||
sourcePaths "phobos"
|
|
||||||
targetPath "generated-lib"
|
|
||||||
#excludedSourceFiles "unittest.d" "test/**" "std/**" "tools/**" "etc/**"
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue