Skip to content

Commit 036806a

Browse files
author
Sam Kleinman
committed
build: refactoring the delegated build, removing awkward create-link script
1 parent 07c40a1 commit 036806a

15 files changed

+274
-229
lines changed

bin/archive/mongodb_docs_meta.py

-30
This file was deleted.

bin/create-link

-29
This file was deleted.

bin/delegated-build

-132
This file was deleted.

bin/htaccess.yaml

+15-1
Original file line numberDiff line numberDiff line change
@@ -1785,9 +1785,23 @@ outputs:
17851785
- 'manual'
17861786
---
17871787
redirect-path: '/tutorial/change-user-password'
1788-
url-base: 'tutorial/control-access-to-mongodb-with-authentication'
1788+
url-base: '/tutorial/control-access-to-mongodb-with-authentication'
17891789
type: 'redirect'
17901790
code: 303
17911791
outputs:
17921792
- 'v2.2'
1793+
---
1794+
redirect-path: '/tutorials'
1795+
url-base: '/tutorial'
1796+
type: 'redirect'
1797+
code: 303
1798+
outputs:
1799+
- 'all'
1800+
---
1801+
redirect-path: '/reference/methods'
1802+
url-base: '/reference/method'
1803+
type: 'redirect'
1804+
code: 303
1805+
outputs:
1806+
- 'all'
17931807
...

bin/makecloth/links.py

+9-15
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77

88
import utils
99
from makecloth import MakefileCloth
10+
from docs_meta import render_paths
1011

1112
# to add a symlink build process, add a tuple to the ``links`` in the builder definitions file.
1213

1314
m = MakefileCloth()
15+
paths = render_paths('dict')
1416

1517
def make_all_links(links):
1618
m.comment('each link is created in the root and then moved into place using the "create-link" script.', block='header')
@@ -22,28 +24,20 @@ def make_all_links(links):
2224
m.comment('meta-targets for testing/integration with rest of the build. must apear at the end', block='footer')
2325
m.newline(block='footer')
2426

25-
m.target('.PHONY', 'links clean-links $(public-output)/manual', block='footer')
27+
m.target('.PHONY', ['links', 'clean-links', '{0}/manual'.format(paths['public'])], block='footer')
2628
m.target('links', '$(LINKS)', block='footer')
2729
m.newline(block='footer')
2830
m.target('clean-links', block='footer')
2931
m.job('rm -rf $(LINKS)', True)
3032

31-
def make_link(make_target, link_target, makefile_block):
32-
link_location = make_target.rsplit('/', 1)[0] + '/'
33+
def make_link(link_path, referent, block):
34+
if block == 'content':
35+
m.append_var('LINKS', link_path)
3336

34-
if makefile_block == 'use':
35-
m.target(link_location, '$(public-branch-output)', makefile_block)
37+
m.target(link_path, block=block)
3638

37-
if makefile_block == 'content':
38-
m.target(make_target, '', makefile_block)
39-
else:
40-
m.append_var('LINKS', make_target, makefile_block)
41-
m.target(make_target, link_location, makefile_block)
42-
43-
44-
m.job('@bin/create-link %s $(notdir $@) %s' % ( link_target, link_location), makefile_block)
45-
m.msg('[symlink]: created a link at: %s' % make_target, makefile_block)
46-
m.newline(block=makefile_block)
39+
m.job(job='fab process.input:{0} process.output:{1} process.create_link'.format(referent, link_path), block=block)
40+
m.newline(block=block)
4741

4842
def main():
4943
conf_file = utils.get_conf_file(__file__)

bin/makecloth/links.yaml

-8
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,4 @@ type: 'structural'
1616
link-path: '$(public-branch-output)/MongoDB-Manual.epub'
1717
referent: 'MongoDB-Manual-$(current-branch).epub'
1818
type: 'content'
19-
---
20-
link-path: '$(public-branch-output)/tutorials'
21-
referent: 'tutorial'
22-
type: 'use'
23-
---
24-
link-path: '$(public-branch-output)/reference/methods'
25-
referent: 'method'
26-
type: 'use'
2719
...

bin/makecloth/pdfs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def pdf_makefile(name, tag):
1616
name_tagged = '-'.join([name, tag])
1717
name_tagged_pdf = name_tagged + '.pdf'
1818
name_tagged_branch_pdf = '-'.join([name, tag, utils.get_branch()]) + '.pdf'
19-
19+
2020
generated_latex = '{0}/latex/{1}.tex'.format(paths['branch-output'], name)
2121
built_tex = '{0}/latex/{1}.tex'.format(paths['branch-output'], name_tagged)
2222

@@ -38,7 +38,7 @@ def pdf_makefile(name, tag):
3838
m.msg('[pdf]: migrated ' + staged_pdf)
3939

4040
m.target(target=staged_pdf, dependency=staged_pdf_branch)
41-
m.job('{0}/create-link {1} {2} {3}'.format(paths['tools'], name_tagged_branch_pdf, name_tagged_pdf, paths['branch-staging']))
41+
m.job('fab process.input:{0} process.output:{1} process.create_link'.format(name_tagged_branch_pdf, staged_pdf))
4242
m.msg('[pdf]: created link for ' + staged_pdf)
4343

4444
m.comment('adding ' + name + '.pdf to the build dependency.')

bin/makecloth/texinfo.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ def build_texinfo_manual(info):
4949
m.msg('[build]: migrated $@')
5050

5151
final_output = '$(public-branch-output)/' + info + '-info.tar.gz'
52-
m.target(target=final_output,
53-
dependency='$(public-branch-output)/' + ofile)
54-
m.job('$(build-tools)/create-link $(notdir $<) $(notdir $@) $(dir $@)')
52+
m.target(target=final_output, dependency='$(public-branch-output)/' + ofile)
53+
m.job('fab process.input:{0} process.output:{1} process.create_link'.format(ofile, final_output))
5554
m.append_var('INFO_OUTPUT', final_output, block='content')
5655

5756

bin/utils.py

+21
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,27 @@ def md5_file(file, block_size=2**20):
1515

1616
return md5.hexdigest()
1717

18+
def run_command(cmd, path, output=None):
19+
if output is None:
20+
try:
21+
output = subprocess.DEVNULL
22+
except AttributeError:
23+
output = open(os.devnull, 'w')
24+
25+
p = subprocess.Popen(cmd, cwd=path, stdout=output, stderr=output)
26+
p.wait()
27+
28+
def get_command_values(cmd, path):
29+
p = subprocess.Popen(cmd, cwd=path, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
30+
r = p.communicate()
31+
return r[0].decode().split('\n')[:-1]
32+
33+
def log_command_output(cmd, path, logfile, wait=False):
34+
with open(logfile, 'a') as f:
35+
p = subprocess.Popen(cmd, cwd=path, stdout=f, stderr=f)
36+
if wait is True:
37+
p.wait()
38+
1839
def shell_value(args, path=None):
1940
if path is None:
2041
path = os.getcwd()

fabfile/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import git
99
import intersphinx
1010
import process
11+
import delegated
1112

1213
import fabric
1314
fabric.state.output.status = False

0 commit comments

Comments
 (0)