Skip to content

Commit

Permalink
add initial support for margo extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
DisposaBoy committed May 7, 2016
1 parent 546aaa4 commit 6bf82a3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
bin/
pkg/
3 changes: 3 additions & 0 deletions gosubl/gs.py
Expand Up @@ -741,6 +741,9 @@ def packages_dir():
def dist_path(*a):
return os.path.join(packages_dir(), 'GoSublime', *a)

def user_path(*a):
return os.path.join(packages_dir(), 'User', 'GoSublime', *a)

def mkdirp(fn):
try:
os.makedirs(fn)
Expand Down
21 changes: 17 additions & 4 deletions gosubl/mg9.py
Expand Up @@ -39,7 +39,7 @@ def gs_init(m={}):
INSTALL_EXE = margo_exe

aso_install_vesion = gs.aso().get('install_version', '')
f = lambda: install(aso_install_vesion, False)
f = lambda: install(aso_install_vesion, True)
gsq.do('GoSublime', f, msg='Installing MarGo', set_status=False)

class Request(object):
Expand Down Expand Up @@ -158,12 +158,19 @@ def install(aso_install_vesion, force_install, _reinstall=False):
gs.notify('GoSublime', 'Installing MarGo')
start = time.time()

cmd = sh.Command(['go', 'build', '-v', '-x', '-o', INSTALL_EXE, 'disposa.blue/margo'])
cmd = sh.Command([
'go', 'build',
'-tags', 'gosublime' if glob.glob(ext_pkg_path('*.go')) else '',
'-i',
'-v',
'-o', INSTALL_EXE,
'disposa.blue/margo',
])
cmd.wd = gs.home_dir_path('bin')
cmd.env = {
'CGO_ENABLED': '0',
'GOBIN': '',
'GOPATH': gs.dist_path(),
'GOPATH': install_gopath(),
}

ev.debug('%s.build' % DOMAIN, {
Expand All @@ -172,7 +179,7 @@ def install(aso_install_vesion, force_install, _reinstall=False):
})

cr = cmd.run()
m_out = 'cmd: `%s`\nstdout: `%s`\nstderr: `%s`\nexception: `%s`' % (
m_out = 'cmd: `%s`\nstdout: `\n%s\n`\nstderr: `\n%s\n`\nexception: `%s`' % (
cr.cmd_lst,
cr.out.strip(),
cr.err.strip(),
Expand Down Expand Up @@ -265,6 +272,12 @@ def f():

return m_out

def ext_pkg_path(*a):
return gs.user_path('src', 'gosublime', *a)

def install_gopath():
return gs.user_path() + os.pathsep + gs.dist_path()

def calltip(fn, src, pos, quiet, f):
tid = ''
if not quiet:
Expand Down
7 changes: 7 additions & 0 deletions src/disposa.blue/margo/gosublime-ext.go
@@ -0,0 +1,7 @@
// +build gosublime

package main

import (
_ "gosublime"
)

0 comments on commit 6bf82a3

Please sign in to comment.