• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1= Vulkan^(R)^ Specification Build Instructions and Notes
2:toc2:
3:toclevels: 2
4
5
6[[intro]]
7== Introduction
8
9This README describes important stuff for getting the Vulkan API
10specification and reference pages building properly.
11
12
13[[building]]
14== Building The Spec
15
16First, clone the Khronos Github repository containing the Vulkan
17specification to your local Linux, Windows, or Mac PC. The repository is
18located at https://github.com/KhronosGroup/Vulkan-Docs/ .
19
20Next, install all the necessary build tools (see <<depends,Software
21Dependencies>> below).
22
23Finally, go to the root directory of your local repository clone, and
24
25    $ make html
26
27builds an HTML5 specification output.
28
29    $ make all
30
31builds the spec targets `html`, `pdf`, `styleguide`, `manhtml`, `manpdf`,
32`manhtmlpages`, `checkinc`, and `checklinks`.
33
34[NOTE]
35.Notes
36====
37  * `make all` takes a long time to run, and generates outputs that are
38    irrelevant for most users.
39    Usually `make html` is used to update the HTML target, which is all
40    that's needed for quick verification and viewing of changes.
41  * The default `make` options build a Vulkan 1.1 specification with no
42    optional extensions.
43  * The `validusage` target is not built as part of `make all`, due to it
44    needing to be built with all extensions enabled. Building this target
45    will fail otherwise.
46====
47
48These targets generate a variety of output documents in the directory
49specified by the Makefile variable `$(OUTDIR)` (by default, `out`).
50The checked-in file `out/index.html` links to all these
51targets, or they can individually be found as follows:
52
53  * API spec:
54  ** `html` - HTML5 in `$(OUTDIR)/html/vkspec.html`
55  ** `pdf` - PDF in `$(OUTDIR)/pdf/vkspec.pdf`
56  * "`Vulkan Documentation and Extensions`" guide:
57  ** `styleguide` - Single-file HTML5 in `$(OUTDIR)/styleguide.html`
58  * Diff spec:
59  ** `diff_html` - Single-file HTML5 in `$(OUTDIR)/html/diff.html`
60  * Reference pages:
61  ** `manhtml` - Single-file HTML in `$(OUTDIR)/apispec.html`
62  ** `manpdf` - Single-file PDF in `$(OUTDIR)/apispec.html`
63  ** `manhtmlpages` - File-per-entry-point HTML in `$(OUTDIR)/man/html/*`
64  * Validator output:
65  ** `checkinc` - List of commands, structs, etc.
66     missing from the API spec in `$(OUTDIR)/checks/notInSpec.txt`
67  ** `checklinks` - Validator script output for API spec in
68     `$(OUTDIR)/checks/specErrs.txt` and for reference pages in
69     `$(OUTDIR)/checks/manErrs.txt`
70  * Valid usage database:
71  ** `validusage` - json database of all valid usage statements in the
72     specification. Must be built with ./makeAllExts (for now).
73     Output in `$(OUTDIR)/validation/validusage.json`.
74     A validated schema for the output of this is stored in
75     `$(CURDIR)/config/vu-to-json/vu_schema.json`
76
77Once you have the basic build working, an appropriate parallelization option
78to make, such as
79
80----
81make -j 8
82----
83
84may significantly speed up the reference page builds.
85
86
87[[build-bugs]]
88=== Asciidoctor Build Errors
89
90If you see an error like this from the `pdf` target:
91
92    /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/ruby-enum-0.7.1/lib/ruby-enum/enum.rb:34:in `const_set': asciidoctor: FAILED: /home/tree/git/vulkan/vkspec.txt: Failed to load AsciiDoc document - wrong constant name default (NameError)
93
94then try <<ruby-enum-downgrade,downgrading ruby-enum>>
95as described below
96
97
98[[building-versions]]
99=== Building Specifications For Different API Versions
100
101The `Makefile` defaults to building a Vulkan 1.1 specification.
102This is controlled by asciidoc attributes passed in the Makefile variable
103`$(VERSIONS)`
104To instead build a Vulkan 1.0 specification, pass
105
106----
107VERSIONS="VK_VERSION_1_0"
108----
109
110on the `make` command line.
111
112
113[[building-extensions]]
114=== Building With Extensions Included
115
116Extensions are defined in the same source as the core Specification, but
117are only conditionally included in the output.
118Asciidoctor http://asciidoctor.org/docs/user-manual/#attributes[attributes]
119of the same name as the extension are used to define whether the extension
120is included or not - defining such an attribute will cause the output to
121include the text for that extension.
122
123When building the specification, the extensions included are those specified
124as a space-separated list of extension names (e.g. `VK_KHR_surface`) in the
125Makefile variable `$(EXTENSIONS)`, normally set on the make command line.
126When changing the list of extensions, it is critical to remove all generated
127files using the `clean_generated` Makefile target, as the contents of
128generated files depends on `$(EXTENSIONS)`.
129There are several helper scripts which clean these files and then build one
130or more specified targets for specified extensions:
131
132  * `makeExt` - generate outputs with one or more extensions enabled.
133    Usage is `makeExt extension-names target(s)`, where `extension-names` is
134    a space-separated list of extension names, such as
135    `VK_EXT_debug_report`.
136    If more than one extension is specified, `extension-names` must be
137    quoted on the command line.
138  * `makeKHR` - generate outputs with all Khronos (`VK_KHR_*`) extensions
139    enabled.
140    Usage is `makeKHR target(s)`.
141
142The `target(s)` passed to these scripts are arbitrary `make` options, and
143can be used to set Makefile variables and options, as well as specify actual
144build targets.
145
146The Makefile variable `$(APITITLE)` defines an additional string which is
147appended to the specification title.
148When building with extensions enabled, this should be set to something like
149`(with extension VK_extension_name)`.
150The `makeExt` and `makeKHR` scripts already do this.
151
152
153[[building-diff]]
154==== Building A Highlighted Extension Diff
155
156The `diff_html` target in the makefile can be used to generate a version of
157the specification which highlights changes made to the specification by the
158inclusion of a particular set of extensions.
159
160Extensions in the Makefile variable `$(EXTENSIONS)` define the base
161extensions to be enabled by the specification, and these will not be
162highlighted in the output.
163Extensions in the Makefile variable `$(DIFFEXTENSIONS)` define the set of
164extensions whose changes to the text will be highlighted when they are
165enabled.
166Any extensions in both variables will be treated as if they were only
167included in `$(DIFFEXTENSIONS)`.
168`$(DIFFEXTENSIONS)` can be set when using the `make*` scripts described
169above.
170
171In the resulting HTML document, content that has been added by one of the
172extensions will be highlighted with a lime background, and content that was
173removed will be highlighted with a pink background.
174Each section has an anchor of `"#differenceN"`, with an arrow (=>) at the end
175of each section which links to the next difference section.
176The first diff section is "difference1".
177
178
179[[building-test]]
180=== Alternate and Test Builds
181
182If you are just testing asciidoc formatting, macros, stylesheets, etc., you
183may want to edit `vkspec.txt` to just include your test code.
184The asciidoctor HTML build is very fast, even for the whole Specification,
185but PDF builds take several minutes.
186
187
188=== Images Used In The Specification
189
190All images used in the specification are in the `images/` directory in SVG
191format, and were created with Inkscape.
192We recommend using Inkscape to modify or create new images, as we've had
193problems using SVG files created by some other tools, especially in the PDF
194builds.
195
196
197=== Validation Scripts
198
199[NOTE]
200.Note
201====
202The validation scripts have not been kept up to date, and probably don't
203work properly at present due to numerous changes in the macro and
204conditional markup used in the specification sources.
205====
206
207There are a several Makefile targets which look for inconsistencies and
208missing material between the specification and ref pages, and the canonical
209description of the API in `vk.xml` :
210
211  * `checkinc`
212  * `checklinks`
213  * `allchecks` - both `checkinc` and `checklinks`
214
215They are necessarily heuristic since they're dealing with lots of
216hand-written material.
217To use them you'll also need to install:
218
219  * `python3`
220
221The `checkinc` target uses Unix filters to determine which autogenerated API
222include files are used (and not used) in the spec.
223It generates several output files, but the only one you're likely to care
224about is `actual.only`.
225This is a list of the include files which are *not* referenced anywhere in
226the spec, and probably correspond to undocumented material in the spec.
227
228The `checklinks` target validates the various internal tagged links in the
229man pages and spec (e.g. the `fname:vkFuncBlah`, `sname:VkStructBlah`, etc.)
230against the canonical description of the API in `vk.xml`.
231It generates two output files, `manErrs.txt` and `specErrs.txt`, which
232report problematic tags and the filenames/lines on which those tags were
233found.
234
235
236[[macros]]
237== Our Asciidoc Macros
238
239We use a bunch of custom macros in the reference pages and API spec asciidoc
240sources.
241The validator scripts rely on these macros as part of their sanity checks,
242and you should use the macros whenever referring to an API command, struct,
243token, or enum name, so the documents are semantically tagged and more
244easily verifiable.
245
246The supported macros are defined in the `config/vulkan-macros/extension.rb`
247asciidoctor extension script.
248
249The tags used are described in the style guide (`styleguide.txt`).
250
251We (may) eventually tool up the spec and ref pages to the point that
252anywhere there's a type or token referred to, clicking on (or perhaps
253hovering over) it in the HTML view and be taken to the definition of that
254type/token.
255That will take some more plumbing work to tag the stuff in the autogenerated
256include files, and do something sensible in the spec (e.g. resolve links to
257internal references).
258
259Most of these macros deeply need more intuitive names.
260
261
262[[refpages]]
263== Reference Pages
264
265The reference pages are extracted from the API Specification source, which
266has been tagged to help identify boundaries of language talking about
267different commands, structures, enumerants, and other types.
268A set of Python scripts extract and lightly massage the relevant tagged
269language into corresponding ref page.
270Pages without corresponding content in the API spec are generated
271automatically, when possible (e.g. for `Vk*FlagBits` pages).
272
273If for some reason you want to regenerate the ref pages from scratch
274yourself, you can do so by
275
276----
277rm man/apispec.txt
278make apispec.txt
279----
280
281The `genRef.py` script will generate many warnings, but most are just
282reminders that some pages are automatically generated.
283If everything is working correctly, all the `man/*.txt` files will be
284regenerated, but their contents will not change.
285
286If you add new API features to the Specification in a branch, make sure that
287the commands have the required tagging and that ref pages are generated for
288them, and build properly.
289
290
291[[styles]]
292== Our stylesheets
293
294We use an HTML stylesheet `config/khronos.css` derived from the
295http://asciidoctor.org/docs/produce-custom-themes-using-asciidoctor-stylesheet-factory/[Asciidoctor
296stylesheet factory] "`colony`" theme, with the default Arial font family
297replaced by the sans-serif https://en.wikipedia.org/wiki/Noto_fonts[Noto
298font family].
299
300
301=== Marking Normative Language
302
303Normative language is marked as *bold*, and also with the [purple]#purple#
304role for HTML output.
305It can be used to mark entire paragraphs or spans of words.
306In addition, the normative terminology macros, such as must: and may: and
307cannot:, always use this role.
308
309The formatting of normative language depends on the stylesheet.
310Currently it just comes out in purple.
311We may add a way to disable this formatting at build time.
312
313
314[[equations]]
315== Imbedding Equations
316
317Where possible, equations should be written using straight asciidoc markup
318with the _eq_ role.
319This covers many common equations and is faster than the alternatives.
320A variety of mathematical symbols are defined using attributes in the
321included `config/attribs.txt`.
322These symbols are defined using attribute names the same as the comparable
323LaTeX macro names, where possible.
324
325For more complex equations, such as multi-case statements, matrices, and
326complex fractions, equations should be written using the latexmath: inline
327and block macros.
328The contents of the latexmath: blocks should be LaTeX math notation.
329LaTeX math markup delimiters are now inserted by the asciidoctor toolchain.
330
331LaTeX math is passed through unmodified to all HTML output forms, which is
332subsequently rendered with the KaTeX engine when the HTML is loaded.
333A local copy of the KaTeX release is kept in `katex/` and
334copied to the HTML output directory during spec generation.
335Math is processed into SVGs via asciidoctor-mathematical for PDF output.
336
337The following caveats apply:
338
339  * The special characters `<` , `>` , and `&` can currently be used only in
340    +++[latexmath]+++ block macros, not in +++latexmath:[]+++ inline macros.
341    Instead use `\lt`, `\leq`, `\gt`, and `\geq` for `<`, `<=`, `>`, and
342    `>=` respectively.
343    `&` is an alignment construct for multiline equations, and should only
344    appear in block macros anyway.
345  * AMSmath environments (e.g. pass:[\begin{equation*}], pass:[{align*}],
346    etc.) cannot be used in KaTeX at present, and have been replaced with
347    constructs supported by KaTeX such as pass:[{aligned}].
348  * Arbitrary LaTeX constructs cannot be used.
349    KaTeX and asciidoctor-mathematical are only equation renderers, not full
350    LaTeX engines.
351    Imbedding LaTeX like \Large or pass:[\hbox{\tt\small VK\_FOO}] may not
352    work in any of the backends, and should be avoided.
353
354See the "`Vulkan Documentation and Extensions`" document for more details of
355supported LaTeX math constructs.
356
357
358[[anchors]]
359== Asciidoc Anchors And Xrefs
360
361In the API spec, sections can have anchors (labels) applied with the
362following syntax.
363In general the anchor should immediately precede the chapter or section
364title and should use the form '+++[[chapter-section-label]]+++'.
365For example,
366
367For example, in chapter `synchronization.txt`:
368
369----
370[[synchronization-primitives]]
371Synchronization Primitives
372----
373
374Cross-references to those anchors can then be generated with, for example,
375
376----
377See the <<synchronization-primitives>> section for discussion of fences,
378semaphores, and events.
379----
380
381You can also add anchors on arbitrary paragraphs, using a similar naming
382scheme.
383
384Anything whose definition comes from one of the autogenerated API include
385files (`.txt` files in the directories `basetypes`, `enums`, `flags`,
386`funcpointers`, `handles`, `protos`, and `structs`) has a corresponding
387anchor whose name is the name of the function, struct, etc.
388being defined.
389Therefore you can say something like:
390
391----
392Fences are used with the +++<<vkQueueSubmit>>+++ command...
393----
394
395
396[[depends]]
397== Software Dependencies
398
399This section describes the software components used by the Vulkan spec
400toolchain.
401
402Before building the Vulkan spec, you must install the following tools.
403Minimum versions known to be working are shown. Later versions will probably
404work at least as well.
405
406  * GNU make (make version: 4.0.8-1; older versions probably OK)
407  * Python 3 (python, version: 3.4.2)
408  * Ruby (ruby, version: 2.3.3)
409  ** The Ruby development package (ruby-dev) may also be required in some
410     environments.
411  * Git command-line client (git, version: 2.1.4).
412    The build can progress without a git client, but branch/commit
413    information will be omitted from the build.
414    Any version supporting the following operations should work:
415  ** `git symbolic-ref --short HEAD`
416  ** `git log -1 --format="%H"`
417  * Ghostscript (ghostscript, version: 9.10).
418    This is for the PDF build, and it can still progress without it.
419    Ghostscript is used to optimize the size of the PDF, so will be a lot
420    smaller if it is included.
421
422The following Ruby Gems and platform package dependencies must also be
423installed.
424This process is described in more detail for individual platforms and
425environment managers below.
426Please read the remainder of this document (other than platform-specific
427parts you don't use) completely before trying to install.
428
429  * Asciidoctor (asciidoctor, version: 1.5.6.1)
430  * Coderay (coderay, version 1.1.2)
431  * JSON Schema (json-schema, version 2.8.0)
432  * Asciidoctor PDF (asciidoctor-pdf, version: 1.5.0.alpha16)
433  * Asciidoctor Mathematical (asciidoctor-mathematical, version 0.2.2)
434  * https://github.com/asciidoctor/asciidoctor-mathematical#dependencies[Dependencies
435    for asciidoctor-mathematical] (There are a lot of these!)
436  * KaTeX distribution (version 0.7.0 from https://github.com/Khan/KaTeX .
437    This is cached under `katex/`, and need not be
438    installed from github.
439
440.Note
441[NOTE]
442====
443Older versions of these packages may work, but are not recommended.
444In particular, the latest versions of asciidoctor-pdf and
445asciidoctor-mathematical contain important patches working around issues
446we've discovered, and those patches may not be present in earlier versions.
447====
448
449Only the `asciidoctor` and `coderay` gems are needed if you don't intend to
450build PDF versions of the spec and supporting documents.
451
452`json-schema` is only required in order to validate the output of the valid
453usage extraction scripts to a JSON file.
454If not installed, validation will be skipped when the JSON is built.
455
456[NOTE]
457.Note
458====
459While it's easier to install just the toolchain components for HTML builds,
460people submitting MRs with substantial changes to the Specification are
461responsible for verifying that their branches build *both* `html` and `pdf`
462targets.
463====
464
465Platform-specific toolchain instructions follow:
466
467  * Microsoft Windows
468  ** <<depends-ubuntu, Ubuntu / Windows 10>>
469  ** <<depends-mingw,MinGW>> (PDF builds not tested)
470  ** <<depends-cygwin, Cygwin>>
471  * <<depends-osx,Mac OS X>>
472  * <<depends-linux,Linux (Debian, Ubuntu, etc.)>>
473
474
475[[depends-windows]]
476=== Windows (General)
477
478Most of the dependencies on Linux packages are light enough that it's
479possible to build the spec natively in Windows, but it means bypassing the
480makefile and calling functions directly.
481This might be solved in future.
482For now, there are three options for Windows users: Ubuntu / Windows 10,
483MinGW, or Cygwin.
484
485
486[[depends-ubuntu]]
487==== Ubuntu / Windows 10
488
489When using the "`Ubuntu Subsystem`" for Windows 10, most dependencies can be
490installed via apt-get:
491
492----
493sudo apt-get -qq -y install build-essential python3 git cmake bison flex \
494    libffi-dev libxml2-dev libgdk-pixbuf2.0-dev libcairo2-dev \
495    libpango1.0-dev ttf-lyx gtk-doc-tools ghostscript
496----
497
498The default ruby packages on Ubuntu are fairly out of date.
499Ubuntu only provides `ruby` and `ruby2.0` - the latter is multiple revisions
500behind the current stable branch, and would require wrangling to get the
501makefile working with it.
502
503Luckily, there are better options; either https://rvm.io[rvm] or
504https://github.com/rbenv/rbenv[rbenv] is recommended to install a more
505recent version.
506
507[NOTE]
508.Note
509====
510
511  * If you are new to Ruby, you should *completely remove* (through the
512    package manager, e.g. `sudo apt-get remove *packagename*`) all existing
513    Ruby and asciidoctor infrastructure on your machine before trying to use
514    rvm or rbenv for the first time.
515    `dpkg -l | egrep 'asciidoctor|ruby|rbenv|rvm'` will give you a list of
516    candidate package names to remove.
517  ** If you already have a favorite Ruby package manager, ignore this
518     advice, and just install the required OS packages and gems.
519  * In addition, `rvm` and `rbenv` are *mutually incompatible*.
520    They both rely on inserting shims and `$PATH` modifications in your bash
521    shell.
522    If you already have one of these installed and are familiar with it,
523    it's probably best to stay with that one.
524    One of the editors, who is new to Ruby, found `rbenv` far more
525    comprehensible than `rvm`.
526    The other editor likes `rvm` better.
527  ** Neither `rvm` nor `rbenv` work, out of the box, when invoked from
528     non-Bash shells like tcsh.
529     This can be hacked up by setting the right environment variables and
530     PATH additions based on a bash environment.
531  * Most of the tools on Bash for Windows are quite happy with Windows line
532    endings (CR LF), but bash scripts expect Unix line endings (LF).
533    The file `.gitattributes` at the top of the vulkan tree in the 1.0
534    branch forces such scripts to be checked out with the proper line
535    endings on non-Linux platforms.
536    If you add new scripts whose names don't end in `.sh`, they should be
537    included in .gitattributes as well.
538====
539
540
541[[depends-ubuntu-rbenv]]
542===== Ubuntu/Windows 10 Using Rbenv
543
544Rbenv is a lighter-weight Ruby environment manager with less functionality
545than rvm.
546Its primary task is to manage different Ruby versions, while rvm has
547additional functionality such as managing "`gemsets`" that is irrelevant to
548our needs.
549
550A complete installation script for the toolchain on Ubuntu for Windows,
551developed on an essentially out-of-the-box environment, follows.
552If you try this, don't try to execute the entire thing at once.
553Do each step separately in case of errors we didn't encounter.
554
555----
556# Install packages needed by `ruby_build` and by toolchain components.
557# See https://github.com/rbenv/ruby-build/wiki and
558# https://github.com/asciidoctor/asciidoctor-mathematical#dependencies
559
560sudo apt-get install autoconf bison build-essential libssl-dev \
561    libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev \
562    libffi-dev libgdbm3 libgdbm-dev cmake libxml2 \
563    libxml2-dev flex pkg-config libglib2.0-dev \
564    libcairo-dev libpango1.0-dev libgdk-pixbuf2.0-dev \
565    libpangocairo-1.0
566
567# Install rbenv from https://github.com/rbenv/rbenv
568git clone https://github.com/rbenv/rbenv.git ~/.rbenv
569
570# Set path to shim layers in .bashrc
571echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> .bashrc
572
573~/.rbenv/bin/rbenv init
574
575# Set .rbenv environment variables in .bashrc
576echo 'eval "$(rbenv init -)"' >> .bashrc
577
578# Restart your shell (e.g. open a new terminal window). Note that
579# you do not need to use the `-l` option, since the modifications
580# were made to .bashrc rather than .bash_profile. If successful,
581# `type rbenv` should print 'rbenv is a function' followed by code.
582
583# Install `ruby_build` plugin from https://github.com/rbenv/ruby-build
584
585git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
586
587# Install Ruby 2.3.3
588# This takes in excess of 20 min. to build!
589# https://github.com/rbenv/ruby-build/issues/1054#issuecomment-276934761
590# suggests:
591# "You can speed up Ruby installs by avoiding generating ri/RDoc
592# documentation for them:
593# RUBY_CONFIGURE_OPTS=--disable-install-doc rbenv install 2.3.3
594# We have not tried this.
595
596rbenv install 2.3.3
597
598# Configure rbenv globally to always use Ruby 2.3.3.
599echo "2.3.3" > ~/.rbenv/version
600
601# Finally, install toolchain components.
602# asciidoctor-mathematical also takes in excess of 20 min. to build!
603# The same RUBY_CONFIGURE_OPTS advice above may apply here as well.
604
605gem install asciidoctor coderay json-schema
606gem install --pre asciidoctor-pdf
607MATHEMATICAL_SKIP_STRDUP=1 gem install asciidoctor-mathematical
608----
609
610
611[[depends-ubuntu-rvm]]
612===== Ubuntu/Windows 10 Using RVM
613
614Here are (sparser) instructions for using rvm to setup version 2.3.x:
615
616----
617gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
618\curl -sSL https://get.rvm.io | bash -s stable --ruby
619source ~/.rvm/scripts/rvm
620rvm install ruby-2.3
621rvm use ruby-2.3
622----
623
624NOTE: Windows 10 Bash will need to be launched with the "-l" option
625appended, so that it runs a login shell; otherwise RVM won't function
626correctly on future launches.
627
628
629[[depends-ubuntu-sys]]
630===== Ubuntu 16.04 using system Ruby
631
632The Ubuntu 16.04.1 default Ruby install (version 2.3.1) seems to be
633up-to-date enough to run all the required gems, but also needs the
634`ruby-dev` package installed through the package manager.
635
636In addition, the library
637`/var/lib/gems/2.3.0/gems/mathematical-1.6.7/ext/mathematical/lib/liblasem.so`
638has to be copied or linked into a directory where the loader can find it.
639This requirement appears to be due to a problem with the
640asciidoctor-mathematical build process.
641
642
643[[depends-mingw]]
644==== MinGW
645
646MinGW can be obtained here: http://www.mingw.org/
647
648Once the installer has run its initial setup, following the
649http://www.mingw.org/wiki/Getting_Started[instructions on the website], you
650should install the `mingw-developer-tools`, `mingw-base` and `msys-base`
651packages.
652The `msys-base` package allows you to use a bash terminal from windows with
653whatever is normally in your path on Windows, as well as the unix tools
654installed by MinGW.
655
656In the native Windows environment, you should also install the following
657native packages:
658
659  * Python 3.x (https://www.python.org/downloads/)
660  * Ruby 2.x (https://rubyinstaller.org/)
661  * Git command-line client (https://git-scm.com/download)
662
663Once this is setup, and the necessary <<depends-gems,Ruby Gems>> are
664installed, launch the `msys` bash shell, and navigate to the spec Makefile.
665From there, you'll need to set `PYTHON=` to the location of your python
666executable for version 3.x before your make command - but otherwise
667everything other than pdf builds should just work.
668
669NOTE: Building the PDF spec via this path has not yet been tested but *may*
670be possible - liblasem is the main issue and it looks like there is now a
671mingw32 build of it available.
672
673
674[[depends-cygwin]]
675==== Cygwin
676
677When installing Cygwin, you should install the following packages via
678`setup`:
679
680----
681// "curl" is only used to download fonts, can be done in another way
682autoconf
683bison
684cmake
685curl
686flex
687gcc-core
688gcc-g++
689ghostscript
690git
691libbz2-devel
692libcairo-devel
693libcairo2
694libffi-devel
695libgdk_pixbuf2.0-devel
696libiconv
697libiconv-devel
698liblasem0.4-devel
699libpango1.0-devel
700libpango1.0_0
701libxml2
702libxml2-devel
703make
704python3
705ruby
706ruby-devel
707----
708
709NOTE: Native versions of some of these packages are usable, but care should
710be taken for incompatibilities with various parts of cygwin - e.g. paths.
711Ruby in particular is unable to resolve Windows paths correctly via the
712native version.
713Python and Git for Windows can be used, though for Python you'll need to set
714the path to it via the PYTHON environment variable, before calling make.
715
716When it comes to installing the mathematical ruby gem, there are two things
717that will require tweaking to get it working.
718Firstly, instead of:
719
720----
721MATHEMATICAL_SKIP_STRDUP=1 gem install asciidoctor-mathematical
722----
723
724You should use
725
726----
727MATHEMATICAL_USE_SYSTEM_LASEM=1 gem install asciidoctor-mathematical
728----
729
730The latter causes it to use the lasem package already installed, rather than
731trying to build a fresh one.
732
733Recent versions of some gems break the installation process and/or pdf build
734on some systems. If the above doesn't work, try:
735
736----
737MATHEMATICAL_USE_SYSTEM_LASEM=1 gem install mathematical -v 1.6.7
738gem install ruby-enum -v 0.7.0
739gem install asciidoctor-mathematical
740----
741
742The mathematical gem also looks for "liblasem" rather than "liblasem0.4" as
743installed by the lasem0.4-devel package, so it is necessary to add a symlink
744to your /lib directory using:
745
746----
747ln -s /lib/liblasem-0.4.dll.a /lib/liblasem.dll.a
748----
749
750<<Ruby Gems>> are not installed to a location that is in your path normally.
751Gems are installed to `~/bin/` - you should add this to your path before
752calling make:
753
754    export PATH=~/bin:$PATH
755
756Finally, you'll need to manually install fonts for lasem via the following
757commands:
758
759----
760mkdir /usr/share/fonts/truetype cd /usr/share/fonts/truetype
761curl -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmex10.ttf \
762     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmmi10.ttf \
763     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmr10.ttf \
764     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmsy10.ttf \
765     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/esint10.ttf \
766     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/eufm10.ttf \
767     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/msam10.ttf \
768     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/msbm10.ttf
769----
770
771
772[[depends-osx]]
773=== Mac OS X
774
775Mac OS X should work in the same way as for ubuntu by using the Homebrew
776package manager, with the exception that you can simply install the ruby
777package via `brew` rather than using a ruby-specific version manager.
778
779You'll likely also need to install additional fonts for the PDF build via
780mathematical, which you can do with:
781
782----
783cd ~/Library/Fonts
784curl -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmex10.ttf \
785     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmmi10.ttf \
786     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmr10.ttf \
787     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmsy10.ttf \
788     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/esint10.ttf \
789     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/eufm10.ttf \
790     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/msam10.ttf \
791     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/msbm10.ttf
792----
793
794Then install the required <<depends-gems,Ruby Gems>>.
795
796
797[[depends-linux]]
798=== Linux (Debian, Ubuntu, etc.)
799
800The instructions for the <<depends-ubuntu,Ubuntu / Windows 10>> installation
801are generally applicable to native Linux environments using Debian packages,
802such as Debian and Ubuntu, although the exact list of packages to install
803may differ.
804Other distributions using different package managers, such as RPM (Fedora)
805and Yum (SuSE) will have different requirements.
806
807Using `rbenv` or `rvm` is neccessary, since the system Ruby packages are
808often well out of date.
809
810Once the environment manager, Ruby, and `ruby_build` have been installed,
811install the required <<depends-gems,Ruby Gems>>.
812
813
814[[depends-gems]]
815=== Ruby Gems
816
817The following ruby gems can be installed directly via the `gem install`
818command, once the platform is set up:
819
820----
821gem install rake asciidoctor coderay json-schema
822
823# Required only for pdf builds
824MATHEMATICAL_SKIP_STRDUP=1 gem install asciidoctor-mathematical
825gem install --pre asciidoctor-pdf
826----
827
828[[ruby-enum-downgrade]]
829==== Ruby Gem Versioning Errors
830
831*ruby-enum*
832
833Make sure you are using ruby-enum 0.7.1 or later, and mathematical 1.6.8 or
834later. If you are forced to use earlier versions, see
835https://github.com/gjtorikian/mathematical/issues/69 for a report of a
836related versioning problem.
837
838
839*prawn*
840
841Make sure you are using prawn 2.2.1 or later, and prawn-templates 0.0.5 or
842later. Incompatibilities between asciidoctor-pdf and earlier versions of
843these gems affects the PDF build. See
844https://github.com/KhronosGroup/Vulkan-Docs/issues/476
845
846
847[[history]]
848== Revision History
849
850  * 2018-03-13 - Rename to BUILD.adoc and update for new directory
851    structure.
852  * 2018-03-05 - Update README for Vulkan 1.1 release.
853  * 2017-03-20 - Add description of prawn versioning problem and how to fix
854    it.
855  * 2017-03-06 - Add description of ruby-enum versioning problem and how to
856    fix it.
857  * 2017-02-13 - Move some comments here from ../../../README.md. Tweak
858    asciidoctor markup to more clearly delineate shell command blocks.
859  * 2017-02-10 - Add more Ruby installation guidelines and reflow the
860    document in accordance with the style guide.
861  * 2017-01-31 - Add rbenv instructions and update the README elsewhere.
862  * 2017-01-16 - Modified dependencies for Asciidoctor
863  * 2017-01-06 - Replace MathJax with KaTeX.
864  * 2016-08-25 - Update for the single-branch model.
865  * 2016-07-10 - Update for current state of spec and ref page generation.
866  * 2015-11-11 - Add new can: etc.
867    macros and DBLATEXPREFIX variable.
868  * 2015-09-21 - Convert document to asciidoc and rename to README.md in the
869    hope the gitlab browser will render it in some fashion.
870  * 2015-09-21 - Add descriptions of LaTeX and MathJax math support for all
871    output formats.
872  * 2015-09-02 - Added Cygwin package info.
873  * 2015-09-02 - Initial version documenting macros, required toolchain
874    components and versions, etc.
875