Skip to content

Commit

Permalink
upgraded to 64 bits, fixed a few issues wrt cygwin priority + previou…
Browse files Browse the repository at this point in the history
…s ocaml install
  • Loading branch information
ncannasse committed Apr 3, 2019
1 parent 91ebdec commit a5481f1
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 19 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ If you have download this as a distribution, simply run `config.bat` to have it

# Build

If you have cloned the repository, you need to run the `Build.exe` script in /build to rebuild the ocamhaxe distribution. This requires Cygwin + Dumpbin.exe windows utility (part of Visual Studio)
If you have cloned the repository, you need to run the `Build.exe` script in /build to rebuild the ocamhaxe distribution. This requires Cygwin 64 bits + Dumpbin.exe windows utility (part of Visual Studio)

Required Cygwin packages are:
Required Cygwin64 packages are:
- wget
- m4
- patch
- unzip
- mingw64-x86_64-gcc-core
- mingw64-x86_64-zlib
- mingw64-x86_64-pcre

(or for 32 bits):
- mingw[64]-i686-gcc-core
- mingw[64]-i686-zlib
- mingw[64]-i686-pcre
Expand Down
Binary file modified haxe/Build.exe
Binary file not shown.
44 changes: 32 additions & 12 deletions haxe/Build.hx
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,23 @@ class Build {
cygCopyFile("bin/"+f);
}
}

function getExePath( exeFile : String ) {
var p = new sys.io.Process("where.exe",[exeFile]);
if( p.exitCode() != 0 )
return null;
var out = StringTools.trim(p.stdout.readAll().toString());
return out.substr(0,-(exeFile.length+1));
}

function detectCygwin() {
var p = new sys.io.Process("where.exe",["cygpath.exe"]);
if( p.exitCode() != 0 ) {
var path = getExePath("cygpath.exe");
if( path == null ) {
log("Cygwin not found");
Sys.exit(1);
}
cygwinPath = StringTools.trim(p.stdout.readAll().toString()).substr(0,-15);
cygwinPath = path.substr(0,-3);
log("Cygwin found in "+cygwinPath);
}

function cygCopyDir( dir : String ) {
Expand Down Expand Up @@ -90,22 +99,26 @@ class Build {
function build() {

// build minimal mingw distrib to use if the user doesn't have cygwin installed

var bits = CFG.is64 ? 64 : 32;
var mingw = CFG.is64 ? "x86_64-w64-mingw32" : "i686-w64-mingw32";

detectCygwin();

Sys.println("Preparing mingw distrib...");
makeDir("mingw/bin");
for( f in CFG.cygwinTools )
cygCopyFile("bin/"+ f + ".exe");
cygCopyDir("usr/i686-w64-mingw32");
cygCopyDir("lib/gcc/i686-w64-mingw32");
cygCopyFile("bin/"+ f.split("$MINGW").join(mingw) + ".exe");
cygCopyDir('usr/$mingw');
cygCopyDir('lib/gcc/$mingw');
makeDir("mingw/tmp");

// build opam repo with packages necessary for haxe

Sys.println("Preparing opam...");

var opam = "opam32.tar.xz";
var ocaml = CFG.ocamlVersion + "+mingw32";
var opam = 'opam$bits.tar.xz';
var ocaml = CFG.ocamlVersion + '+mingw$bits';

if( !sys.FileSystem.exists("bin") ) {
// install opam
Expand All @@ -116,21 +129,28 @@ class Build {
deleteFile("install.sh");
}

// copy necessary runtime files so they are added to PATH in Config
// copy necessary runtime files from our local mingw to our local bin so they are added to PATH in Config
for( lib in CFG.mingwLibs ) {
var out = "bin/"+lib+".dll";
if( !sys.FileSystem.exists(out) )
sys.io.File.copy("mingw/usr/i686-w64-mingw32/sys-root/mingw/bin/"+lib+".dll",out);
sys.io.File.copy('mingw/usr/$mingw/sys-root/mingw/bin/'+lib+".dll",out);
}

var cwd = Sys.getCwd().split("\\").join("/");
var opamRoot = cwd+".opam";

// temporarily modify the env
// setting cygwin with highest priority is necessary
Sys.putEnv("PATH", cwd+"bin;" + cygwinPath + ";" + Sys.getEnv("PATH"));
Sys.putEnv("PATH", [
cwd+"bin",
cygwinPath + "bin",
opamRoot+"/"+ocaml+"/bin",
Sys.getEnv("PATH")
].join(";"));
Sys.putEnv("OPAMROOT", opamRoot);

Sys.putEnv("OCAMLLIB", opamRoot+"/"+ocaml+"/lib/ocaml");
Sys.putEnv("OCAMLFIND_CONF", opamRoot+"/"+ocaml+"/lib/findlib.conf");

if( !sys.FileSystem.exists(opamRoot) )
cygCommand("opam",["init","--yes","default","https://github.com/fdopen/opam-repository-mingw.git","--comp",ocaml,"--switch",ocaml]);

Expand Down
Binary file modified haxe/Config.exe
Binary file not shown.
10 changes: 6 additions & 4 deletions haxe/Config.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
class Config {

static var CFG : {
var is64 : Bool;
var ocamlVersion : String;
var cygwinTools : Array<String>;
var mingwLibs : Array<String>;
Expand Down Expand Up @@ -77,14 +78,15 @@ class Config {
cygwinPath = StringTools.trim(p.stdout.readAll().toString()).substr(0,-15);
log("Cygwin found in "+cygwinPath);

var mingw = CFG.is64 ? "x86_64-w64-mingw32" : "i686-w64-mingw32";
for( f in CFG.cygwinTools )
if( !sys.FileSystem.exists(cygwinPath+"/bin/"+f+".exe") )
if( !sys.FileSystem.exists(cygwinPath+"/bin/"+f.split("$MINGW").join(mingw)+".exe") )
throw "Missing required cygwin tool: "+f;

var mingw = cygwinPath+"/usr/i686-w64-mingw32/sys-root/mingw";
var mingwPath = cygwinPath+'/usr/$mingw/sys-root/mingw';
for( lib in CFG.mingwLibs )
if( !sys.FileSystem.exists(mingw+"/bin/"+lib+".dll") )
throw "Missing mingw library: "+lib+" (in "+mingw+"/bin)";
if( !sys.FileSystem.exists('$mingwPath/bin/$lib.dll') )
throw "Missing mingw library: "+lib+" (in "+mingwPath+"/bin)";

} else {
log("Cygwin not found");
Expand Down
3 changes: 2 additions & 1 deletion haxe/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"is64": true,
"ocamlVersion" : "4.03.0",
"cygwinTools" : ["bash", "cygpath", "i686-w64-mingw32-ar", "i686-w64-mingw32-as", "i686-w64-mingw32-gcc", "i686-w64-mingw32-ld", "i686-w64-mingw32-ranlib", "ls", "make", "mkdir", "wget", "mv", "rm", "sed", "sh", "stty", "tput", "tr", "true", "cp", "m4"],
"cygwinTools" : ["bash", "cygpath", "$MINGW-ar", "$MINGW-as", "$MINGW-gcc", "$MINGW-ld", "$MINGW-ranlib", "ls", "make", "mkdir", "wget", "mv", "rm", "sed", "sh", "stty", "tput", "tr", "true", "cp", "m4"],
"mingwLibs" : ["zlib1", "libpcre-1"],
"opamLibs" : ["sedlex","camlp4","merlin","extlib","xml-light","rope","ptmap","sha"]
}

0 comments on commit a5481f1

Please sign in to comment.