| 1 |
BUILDING rdiscount |
| 2 |
================== |
| 3 |
|
| 4 |
You'll be needing Ruby, rake, and a basic build environment. |
| 5 |
|
| 6 |
Build the rdiscount extension for tests and local development: |
| 7 |
|
| 8 |
$ rake build |
| 9 |
|
| 10 |
Use your rdiscount working copy when running ruby programs: |
| 11 |
|
| 12 |
$ export RUBYLIB=~/rdiscount/lib:$RUBYLIB |
| 13 |
$ ruby some-program.rb |
| 14 |
|
| 15 |
Gathering changes from an upstream discount clone requires first |
| 16 |
grabbing the discount submodule into the root of the project and then running |
| 17 |
the rake gather task to copy discount source files into the ext/ directory: |
| 18 |
|
| 19 |
$ git submodule update --init |
| 20 |
Submodule 'discount' ([email protected]:Orc/discount.git) registered for path 'discount' |
| 21 |
Cloning into discount... |
| 22 |
$ cd discount |
| 23 |
$ ./configure.sh |
| 24 |
$ make # ensure it compiles |
| 25 |
$ cd .. |
| 26 |
$ rake gather |
| 27 |
$ rake build |
| 28 |
|
| 29 |
|
| 30 |
UPGRADING Discount |
| 31 |
================== |
| 32 |
|
| 33 |
The most common maintenance task is upgrading the version of Discount that |
| 34 |
RDiscount is using. |
| 35 |
|
| 36 |
Before doing anything, make sure you can build the current (unmodified) version |
| 37 |
of RDiscount. See the section above for details. |
| 38 |
|
| 39 |
Update the Discount submodule to the desired version: |
| 40 |
|
| 41 |
$ cd discount |
| 42 |
$ git fetch |
| 43 |
$ git checkout v2.0.7.x # insert desired version |
| 44 |
$ cd .. |
| 45 |
|
| 46 |
Copy the new Discount sources to the appropriate directories for RDiscount: |
| 47 |
|
| 48 |
$ rake gather |
| 49 |
|
| 50 |
Update rdiscount.gemspec to include all *.c, *.h, and *.rb files in ext: |
| 51 |
|
| 52 |
$ rake rdiscount.gemspec |
| 53 |
|
| 54 |
Build the RDiscount gem. If you get errors related to missing files |
| 55 |
in ext, make sure you updated the gemspec correctly in the previous step. |
| 56 |
|
| 57 |
$ gem build rdiscount.gemspec |
| 58 |
|
| 59 |
Install this new gem locally. It is recommended that you use RVM to |
| 60 |
create an isolated installation environment. If you get an error after the line |
| 61 |
"Building native extensions", see the troubleshooting section below. |
| 62 |
|
| 63 |
$ rvm ruby@rdiscount --create # recommended; requires RVM |
| 64 |
$ gem install rdiscount-*.gem |
| 65 |
|
| 66 |
Make sure the gem can be imported: |
| 67 |
|
| 68 |
$ ruby -e 'require "rdiscount"' |
| 69 |
|
| 70 |
Make sure the tests (still) pass: |
| 71 |
|
| 72 |
$ rake test |
| 73 |
|
| 74 |
Worked? Swell! The hard part is past. |
| 75 |
|
| 76 |
Check the Discount release notes to determine whether it has gained any new |
| 77 |
features that should be exposed through the RDiscount Ruby interface |
| 78 |
(lib/rdiscount.rb), such as new MKD_* flags or configure flags. |
| 79 |
If so, update the Ruby interface. |
| 80 |
|
| 81 |
If the ./configure.sh line needs to be changed to support new features, |
| 82 |
you will need to port some #defines from discount/config.h to ext/config.h |
| 83 |
manually to get RDiscount's embedded Discount to use the same configure flags. |
| 84 |
|
| 85 |
For new Discount extensions via new MKD_* flags, you will need to update: |
| 86 |
|
| 87 |
* lib/rdiscount.rb with new accessors and |
| 88 |
* the rb_rdiscount__get_flags function in ext/rdiscount.c with new |
| 89 |
accessor-to-flag mappings for each new extension. |
| 90 |
|
| 91 |
You should also look for RDiscount-specific bugs & feature requests in the |
| 92 |
GitHub tracker and fix a few. |
| 93 |
|
| 94 |
If any bugs were fixed or features added be sure to also add new tests! |
| 95 |
And don't forget to rerun the preexisting tests. |
| 96 |
|
| 97 |
Update the CHANGELOG. |
| 98 |
|
| 99 |
Update rdiscount.gemspec with the new RDiscount version number. |
| 100 |
Also update the VERSION constant in lib/rdiscount.rb. |
| 101 |
Push that change as the final commit with a message in the format |
| 102 |
"2.0.7 release". |
| 103 |
|
| 104 |
Tag the release commit: |
| 105 |
|
| 106 |
$ git tag 2.0.7 # insert desired version |
| 107 |
|
| 108 |
Rebuild the gem file and push it to RubyGems. |
| 109 |
|
| 110 |
$ gem build rdiscount.gemspec |
| 111 |
$ gem push rdiscount-NEW_VERSION.gem |
| 112 |
|
| 113 |
Announce the new release! For releases with new features it is recommended to |
| 114 |
write a full blog post. |
| 115 |
|
| 116 |
|
| 117 |
Troubleshooting Native Extension Issues |
| 118 |
--------------------------------------- |
| 119 |
|
| 120 |
The most likely place where errors will crop up is when you attempt to build |
| 121 |
the C extension. If this happens, you will have to debug manually. Below are |
| 122 |
a few recommended sanity checks: |
| 123 |
|
| 124 |
Ensure the Makefile is generated correctly: |
| 125 |
|
| 126 |
$ cd ext |
| 127 |
$ ruby extconf.rb |
| 128 |
|
| 129 |
Ensure make succeeds: |
| 130 |
|
| 131 |
$ make |
| 132 |
|
| 133 |
If you get linker errors related to there being duplicate symbols for _main, |
| 134 |
you probably need to update the deploy target of the Rakefile to exclude |
| 135 |
new *.c files from Discount that have a main function. |
| 136 |
|
| 137 |
For issues related to config.h or extconf.rb, there was probably some |
| 138 |
change to Discount's configure.sh that broke them. You will probably need |
| 139 |
to update these files in ext/ manually. |
| 140 |
|
| 141 |
For other errors, you'll have to investigate yourself. Common error classes: |
| 142 |
* 'ext/configure.sh' fails: |
| 143 |
- Create a patch to the upstream Discount. |
| 144 |
* Some files missing from ext/ that are present in discount/: |
| 145 |
- Update 'rake deploy' target to copy more files. |
| 146 |
* Some files missing when `gem build` is run: |
| 147 |
- Update gemspec to enumerate the correct files in ext/. |