Skip to content

Commit

Permalink
move combine zips to build_all script
Browse files Browse the repository at this point in the history
- gets rid of extra copying and additional complexity
  in the create_dmd_release script
  • Loading branch information
MartinNowak committed Mar 1, 2015
1 parent 6f21b12 commit 6b93388
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 111 deletions.
41 changes: 24 additions & 17 deletions create_dmd_release/build_all.d
Expand Up @@ -237,7 +237,7 @@ void prepareExtraBins(string workDir)
//------------------------------------------------------------------------------
// builds a dmd.VERSION.OS.MODEL.zip on the vanilla VirtualBox image

void runBuild(Box box, string ver, bool isBranch, bool combine, bool skipDocs)
void runBuild(Box box, string ver, bool isBranch, bool skipDocs)
{
auto sh = box.shell();

Expand Down Expand Up @@ -278,14 +278,10 @@ void runBuild(Box box, string ver, bool isBranch, bool combine, bool skipDocs)
cmd ~= " " ~ ver;

sh.exec(cmd);
if (combine)
sh.exec(rdmd~" create_dmd_release -v --extras=extraBins --combine --use-clone=clones "~ver);

sh.close();

// copy out created zip files
box.scp("default:dmd."~ver~"."~box.platform~".zip", "build/");
if (combine)
box.scp("default:dmd."~ver~".zip", "build/");

// Build package installers
if (!isBranch && !skipDocs) final switch (box._os)
Expand Down Expand Up @@ -336,6 +332,25 @@ void cloneSources(string gitTag, string tgtDir)
write(tgtDir~"/dmd/VERSION", gitTag.chompPrefix("v"));
}

void combineZips(string gitTag)
{
auto workDir = mkdtemp();
scope (success) if (workDir.exists) rmdirRecurse(workDir);

auto baseName = "build/dmd."~gitTag;
writefln("Creating combined '%s.zip'.", baseName);
foreach (os; ["windows", "linux", "freebsd", "osx"])
{
auto name = baseName ~ "." ~ os;
foreach (suf; [".zip", "-32.zip", "-64.zip"])
{
if (exists(name ~ suf))
extractZip(name ~ suf, workDir);
}
}
archiveZip(workDir~"/dmd2", baseName~".zip");
}

int error(Args...)(string fmt, Args args)
{
stderr.write("\033[031m");
Expand Down Expand Up @@ -393,10 +408,8 @@ int main(string[] args)
immutable ver = gitTag.chompPrefix("v");
mkdirRecurse("build");

foreach (i, box; boxes)
foreach (box; boxes)
{
immutable combine = i == boxes.length - 1;

box.up();
scope (success) box.destroy();
scope (failure) box.halt();
Expand All @@ -406,14 +419,8 @@ int main(string[] args)
// copy create_dmd_release.d and dependencies
box.scp("create_dmd_release.d common.d", "default:");

// copy all zips into the last box to combine them
if (combine && boxes.length > 1)
{
toCopy = boxes[0 .. $ - 1].map!(b => "build/dmd."~ver~"."~b.platform~".zip").join(" ");
box.scp(toCopy, "default:");
}

runBuild(box, ver, isBranch, combine, skipDocs);
runBuild(box, ver, isBranch, skipDocs);
}
combineZips(ver);
return 0;
}
105 changes: 11 additions & 94 deletions create_dmd_release/create_dmd_release.d
Expand Up @@ -45,13 +45,7 @@ If a working multilib system is any trouble, you can also build 32-bit and
View all options with "create_dmd_release --help".
3. Copy the resulting .zip files to a single directory on any
non-Windows machine (Windows would mess up the symlinks and executable
attributes), and generate the combined-OS release like this:
$ [path-to]/create_dmd_release v2.064 --combine
4. Distribute all the .zip and .7z files.
3. Distribute all the .zip and .7z files.
Extra notes:
------------
Expand All @@ -61,22 +55,15 @@ This tool keeps a deliberately strong separation between each of the main stages
2. Build (compile everything, including docs, within the temp dir)
3. Package (generate an OS-specific release as a directory)
4. Archive (zip the OS-specific packaged release directory)
5. Combine (create the all-OS release archive from multiple OS-specific ones)
Aside from helping to ensure correctness, this separation means the process
can be resumed or restarted beginning at any of the above steps (see
the --skip-* flags in the --help screen).
The last two steps, archive and combine, are not performed by default. To
The last step archive is not performed by default. To
perform the archive step, supply the --archive flag.
You can create an archive without repeating the earlier clone/build/package
steps by including the --skip-package flag.
The final step, combine, is completely separate. You must first run this tool
on each of the target OSes to create the OS-specific archives. Then copy all
the archives to a single directory on any Posix system (not Windows because
that would destroy the symlinks and executable attributes in the posix
archives). Then, from that directory, run this tool with the --combine flag.
+/

import std.algorithm;
Expand All @@ -95,18 +82,9 @@ import common;
version(Posix)
import core.sys.posix.sys.stat;

immutable osDirNameWindows = "windows";
immutable osDirNameFreeBSD = "freebsd";
immutable osDirNameLinux = "linux";
immutable osDirNameOSX = "osx";

immutable releaseBitSuffix32 = "-32"; // Ex: "dmd.v2.064.linux-32.zip"
immutable releaseBitSuffix64 = "-64";

immutable allOsDirNames = [
osDirNameFreeBSD, osDirNameOSX, osDirNameWindows, osDirNameLinux
];

version(Windows)
{
// Cannot start with a period or MS's HTML Help Workshop will fail
Expand All @@ -128,7 +106,7 @@ version(Windows)
// official Win64 build/makefile of DMD. This is a hack to work around that.
immutable lib64RequiresDmd32 = true;

immutable osDirName = osDirNameWindows;
immutable osDirName = "windows";
immutable make = "make";
immutable suffix32 = ""; // bin/lib TODO: adapt scripts to use 32
immutable suffix64 = "64"; // bin64/lib64
Expand All @@ -149,11 +127,11 @@ else version(Posix)
immutable lib64RequiresDmd32 = false;

version(FreeBSD)
immutable osDirName = osDirNameFreeBSD;
immutable osDirName = "freebsd";
else version(linux)
immutable osDirName = osDirNameLinux;
immutable osDirName = "linux";
else version(OSX)
immutable osDirName = osDirNameOSX;
immutable osDirName = "osx";
else
static assert(false, "Unsupported system");

Expand Down Expand Up @@ -244,19 +222,13 @@ void showHelp()
--archive Create platform-specific zip archive.
--combine (Posix-only) Combine all platform-specific archives in
current directory into cross-platform zip archive.
Cannot be used on Windows because the symlinks and
executable attributes would be destroyed.
Implies --skip-package.
--clean Delete temporary dir (see above) and exit.
--only-32 Only build and package 32-bit.
--only-64 Only build and package 64-bit.
On OSX, --only-32 and --only-64 are not recommended because universal
binaries will NOT be created, even when using --combine.
binaries will NOT be created.
`).outdent().strip()
);
}
Expand All @@ -268,7 +240,6 @@ bool skipBuild;
bool skipPackage;
bool skipDocs;
bool doArchive;
bool doCombine;
bool do32Bit;
bool do64Bit;

Expand Down Expand Up @@ -316,7 +287,6 @@ int main(string[] args)
"clean", &clean,
"extras", &customExtrasDir,
"archive", &doArchive,
"combine", &doCombine,
"only-32", &do32Bit,
"only-64", &do64Bit,
);
Expand Down Expand Up @@ -358,15 +328,6 @@ int main(string[] args)
return 1;
}

version(Windows)
{
if(doCombine)
{
errorMsg("--combine cannot be used on Windows because the symlinks and executable attributes would be destroyed.");
return 1;
}
}

if(do32Bit && do64Bit)
{
errorMsg("--only-32 and --only-64 cannot be used together.");
Expand All @@ -377,30 +338,27 @@ int main(string[] args)
{
if(do32Bit || do64Bit)
{
infoMsg("WARNING: Using --only-32 and --only-64: Universal binaries will not be created, even when using --combine.");
infoMsg("WARNING: Using --only-32 and --only-64: Universal binaries will not be created.");
return 1;
}
}

if(!do32Bit && !do64Bit)
do32Bit = do64Bit = true;

if(doCombine)
skipPackage = true;

if(skipPackage)
skipBuild = true;

if(cloneDir != "" || skipBuild)
skipClone = true;

if(skipPackage && !doArchive && !doCombine)
if(skipPackage && !doArchive)
{
errorMsg("Nothing to do! Specified --skip-package, but neither --archive nor --combine flag");
errorMsg("Nothing to do! Specified --skip-package, but not --archive.");
return 1;
}

if(customExtrasDir == "" && !doCombine)
if(customExtrasDir == "")
{
errorMsg("--extras=path is required.\nSee --help for more info.");
return 1;
Expand Down Expand Up @@ -451,12 +409,6 @@ int main(string[] args)
if(doArchive)
createZip(branch);

if(doCombine)
extractOsArchives(branch);

if(doCombine)
createCombinedZip(branch);

infoMsg("Done!");
}
catch(Fail e)
Expand Down Expand Up @@ -1052,41 +1004,6 @@ void createZip(string branch)
archiveZip(releaseDir~"/dmd2", archiveName);
}

void extractOsArchives(string branch)
{
auto outputDir = "dmd."~branch;
removeDir(outputDir);
makeDir(outputDir);

foreach(osName; allOsDirNames)
{
auto archiveName = "dmd."~branch~"."~osName;

auto archiveZip = archiveName~".zip";

// Try combined 32/64-bit archives
if(exists(archiveZip))
extractZip(archiveZip, outputDir);
else
{
// Try 32-bit only and 64-bit-only
foreach(bitSuffix; TypeTuple!(releaseBitSuffix64, releaseBitSuffix32))
{
archiveZip = archiveName~bitSuffix~".zip";

if(exists(archiveZip))
extractZip(archiveZip, outputDir);
}
}
}
}

void createCombinedZip(string branch)
{
auto dirName = "dmd."~branch;
archiveZip(dirName~"/dmd2", dirName~".zip");
}

// Utils -----------------------

void verboseMsg(lazy string msg)
Expand Down

0 comments on commit 6b93388

Please sign in to comment.