Well, this is the cleaned up version. We do check for dev packages on ubuntu, 
check if tmp dir already exists and delete tmp dir when done. Problem with mode 
= Whatif was that Whatif is a pure enum, issue is posted. The modules still 
import each other directly, without the gintro prefix. Seems to work fine, I 
hope that is indeed intended and desired.

I can install my local package fine with "nimble prepare", "nimble install". 
From bug

[https://github.com/nim-lang/nimble/issues/280](https://github.com/nim-lang/nimble/issues/280)

I think I can not avoid that nimble prepare. But I am still not sure if "nimble 
prepare" will work for remote packages at all!
    
    
    $ cat gintro.nimble
    # Package
    
    version       = "0.1.0"
    author        = "Stefan Salewski"
    description = "High level GObject-Introspection based GTK3 bindings"
    license       = "MIT"
    skipDirs = @["tests"]
    
    # Dependencies
    
    requires "nim >= 0.17.0"
    
    when defined(nimdistros):
      import distros
      if detectOs(Ubuntu) or detectOs(Debian):
        foreignDep "libgtk-3-dev"
      elif detectOs(Gentoo):
        foreignDep "gtk+" # can we specify gtk3?
      #else: we don't know the names for all the other distributions
      #  foreignDep "openssl"
    
    import ospaths
    
    proc prep =
      let this = thisDir()
      let td = getTempDir()
      cd(td)
      let wd = "gintrosalewski"
      if dirExists(wd):
        quit("gintro: tmp directory already exists!")
      mkDir(wd)
      cd(wd)
      mkDir("ngtk3")
      cd("ngtk3")
      
      exec("git clone https://github.com/ngtk3/nim-gdk_pixbuf";)
      exec("git clone https://github.com/ngtk3/common";)
      exec("git clone https://github.com/ngtk3/nim-atk";)
      exec("git clone https://github.com/ngtk3/nim-cairo";)
      exec("git clone https://github.com/ngtk3/nim-gdk3";)
      exec("git clone https://github.com/ngtk3/nim-gio";)
      exec("git clone https://github.com/ngtk3/nim-glib";)
      exec("git clone https://github.com/ngtk3/nim-gobject";)
      exec("git clone https://github.com/ngtk3/nim-gtk3";)
      exec("git clone https://github.com/ngtk3/nim-pango";)
      exec("git clone https://github.com/ngtk3/nim-gir";)
      
      cpFile(this / "tests" / "gen.nim", td / wd / "gen.nim")
      cpFile(this / "tests" / "combinatorics.nim", td / wd / 
"combinatorics.nim")
      
      cpFile("nim-gio/src/gio.nim", td / wd / "gio.nim")
      cpFile("nim-atk/src/atk.nim", td / wd / "atk.nim")
      cpFile("nim-glib/src/glib.nim", td / wd / "glib.nim")
      cpFile("nim-gdk3/src/gdk3.nim", td / wd / "gdk3.nim")
      cpFile("nim-gtk3/src/gtk3.nim", td / wd / "gtk3.nim")
      cpFile("nim-gobject/src/gobject.nim", td / wd / "gobject.nim")
      cpFile("nim-cairo/src/cairo.nim", td / wd / "cairo.nim")
      cpFile("nim-cairo/src/cairo_pragma.nim", td / wd / "cairo_pragma.nim")
      cpFile("nim-pango/src/pango.nim", td / wd / "pango.nim")
      cpFile("nim-pango/src/pango_cairo.nim", td / wd / "pango_cairo.nim")
      cpFile("nim-gdk_pixbuf/src/gdk_pixbuf.nim", td / wd / "gdk_pixbuf.nim")
      cpFile("nim-gir/src/gir.nim", td / wd / "gir.nim")
      
      cd(td)
      cd(wd)
      exec("nim c gen.nim")
      mkDir("nim_gi")
      exec(td / wd / "gen")
      let mods = listFiles("nim_gi")
      for i in mods:
        let j = i[7 .. ^1]
        cpFile(i, this / "gintro" / j)
      cd(td)
      rmDir(wd) # cleanup
    
    task prepare, "preparing gintro":
    #before install:
      
      echo "preparing gintro"
      prep()
    
    

Reply via email to