passenger 5.0.28 → 5.0.29
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of passenger might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.editorconfig +5 -0
- data/CHANGELOG +13 -0
- data/build/apache2.rb +3 -3
- data/build/common_library.rb +3 -3
- data/build/nginx.rb +4 -4
- data/build/packaging.rb +9 -8
- data/build/support/cxx_dependency_map.rb +9 -7
- data/build/support/general.rb +39 -0
- data/build/support/vendor/cxxcodebuilder/CxxCodeBuilder.sublime-project +8 -0
- data/build/support/vendor/cxxcodebuilder/Gemfile +4 -0
- data/build/support/vendor/cxxcodebuilder/Gemfile.lock +28 -0
- data/build/support/vendor/cxxcodebuilder/LICENSE.md +19 -0
- data/build/support/vendor/cxxcodebuilder/README.md +98 -0
- data/build/support/vendor/cxxcodebuilder/Rakefile +4 -0
- data/build/support/vendor/cxxcodebuilder/lib/cxxcodebuilder.rb +23 -0
- data/build/support/vendor/cxxcodebuilder/lib/cxxcodebuilder/builder.rb +574 -0
- data/build/support/vendor/cxxcodebuilder/lib/cxxcodebuilder/initializer_builder.rb +166 -0
- data/build/test_basics.rb +2 -1
- data/resources/templates/standalone/server.erb +6 -4
- data/src/agent/Core/Controller/ForwardResponse.cpp +5 -5
- data/src/agent/Watchdog/WatchdogMain.cpp +0 -10
- data/src/apache2_module/ConfigurationCommands.cpp +181 -248
- data/src/apache2_module/ConfigurationCommands.cpp.cxxcodebuilder +127 -0
- data/src/apache2_module/ConfigurationFields.hpp +135 -51
- data/src/apache2_module/ConfigurationFields.hpp.cxxcodebuilder +113 -0
- data/src/apache2_module/ConfigurationSetters.cpp +414 -459
- data/src/apache2_module/ConfigurationSetters.cpp.cxxcodebuilder +144 -0
- data/src/apache2_module/CreateDirConfig.cpp +49 -52
- data/src/apache2_module/CreateDirConfig.cpp.cxxcodebuilder +81 -0
- data/src/apache2_module/Hooks.cpp +0 -14
- data/src/apache2_module/MergeDirConfig.cpp +136 -226
- data/src/apache2_module/MergeDirConfig.cpp.cxxcodebuilder +97 -0
- data/src/apache2_module/SetHeaders.cpp +92 -143
- data/src/apache2_module/SetHeaders.cpp.cxxcodebuilder +106 -0
- data/src/cxx_supportlib/Constants.h +86 -146
- data/src/cxx_supportlib/Constants.h.cxxcodebuilder +43 -0
- data/src/cxx_supportlib/DataStructures/LString.h +40 -23
- data/src/cxx_supportlib/MemoryKit/mbuf.cpp +60 -25
- data/src/cxx_supportlib/MemoryKit/mbuf.h +50 -25
- data/src/cxx_supportlib/ServerKit/CookieUtils.h +36 -3
- data/src/cxx_supportlib/ServerKit/HeaderTable.h +2 -8
- data/src/cxx_supportlib/ServerKit/HttpServer.h +6 -15
- data/src/cxx_supportlib/WatchdogLauncher.cpp +4 -4
- data/src/cxx_supportlib/WatchdogLauncher.h +2 -3
- data/src/nginx_module/CacheLocationConfig.c +623 -780
- data/src/nginx_module/CacheLocationConfig.c.cxxcodebuilder +214 -0
- data/src/nginx_module/Configuration.h +1 -1
- data/src/nginx_module/ConfigurationCommands.c +404 -535
- data/src/nginx_module/ConfigurationCommands.c.cxxcodebuilder +157 -0
- data/src/nginx_module/CreateLocationConfig.c +82 -206
- data/src/nginx_module/CreateLocationConfig.c.cxxcodebuilder +98 -0
- data/src/nginx_module/LocationConfig.h +97 -0
- data/src/nginx_module/LocationConfig.h.cxxcodebuilder +131 -0
- data/src/nginx_module/MergeLocationConfig.c +157 -278
- data/src/nginx_module/MergeLocationConfig.c.cxxcodebuilder +144 -0
- data/src/nginx_module/ngx_http_passenger_module.c +4 -10
- data/src/ruby_supportlib/phusion_passenger.rb +4 -4
- data/src/ruby_supportlib/phusion_passenger/config/validate_install_command.rb +2 -2
- data/src/ruby_supportlib/phusion_passenger/packaging.rb +2 -0
- data/src/ruby_supportlib/phusion_passenger/platform_info/compiler.rb +6 -0
- data/src/ruby_supportlib/phusion_passenger/platform_info/cxx_portability.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/standalone/start_command.rb +27 -8
- data/src/ruby_supportlib/phusion_passenger/vendor/daemon_controller.rb +120 -2
- data/src/ruby_supportlib/phusion_passenger/vendor/daemon_controller/lock_file.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/vendor/daemon_controller/spawn.rb +4 -4
- data/src/ruby_supportlib/phusion_passenger/vendor/daemon_controller/version.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/api.rb +5 -5
- metadata +24 -15
- data/src/apache2_module/ConfigurationCommands.cpp.erb +0 -109
- data/src/apache2_module/ConfigurationFields.hpp.erb +0 -98
- data/src/apache2_module/ConfigurationSetters.cpp.erb +0 -128
- data/src/apache2_module/CreateDirConfig.cpp.erb +0 -72
- data/src/apache2_module/MergeDirConfig.cpp.erb +0 -82
- data/src/apache2_module/SetHeaders.cpp.erb +0 -91
- data/src/cxx_supportlib/Constants.h.erb +0 -41
- data/src/nginx_module/CacheLocationConfig.c.erb +0 -171
- data/src/nginx_module/ConfigurationCommands.c.erb +0 -144
- data/src/nginx_module/ConfigurationFields.h +0 -145
- data/src/nginx_module/ConfigurationFields.h.erb +0 -112
- data/src/nginx_module/CreateLocationConfig.c.erb +0 -78
- data/src/nginx_module/MergeLocationConfig.c.erb +0 -118
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de34a89bcd92faaf4c870691894fdc98545e933f
|
4
|
+
data.tar.gz: de6ab1650b829f01146d3851f85cc38f347b02f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fec73a5f401c95111c03dde4e99f2d393d2b340e82ced8e051c11862f8810ca8f9d6b5164701622d6e1e80655f58ac6859297dbff1089f0ae4a7c4a939bcfc35
|
7
|
+
data.tar.gz: 8aa0e543b0ef031f56ef902f67e6ac6b6e032cf057cac7c9562d21b095d70ad8c14194e278ff692acd5e62a3ae0904f65b1f050946ed0993854e14af1cf8d762
|
data/.editorconfig
CHANGED
data/CHANGELOG
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
Release 5.0.29
|
2
|
+
--------------
|
3
|
+
|
4
|
+
* Fixes the FreeBSD build breaking due to the `-ldl` flag introduced by the LVE integration patch (5.0.28). Closes GH-1805.
|
5
|
+
* Fixes per-application interpreter override (ruby, node, python) being ignored in mass deployment mode. Closes GH-1818.
|
6
|
+
* Fixes incomplete refactor from 5.0.27 that could, under specific conditions, lead to a Passenger crash. Closes GH-1794.
|
7
|
+
* [Apache] Remove unused code that caused a crash in configurations with thousands of VirtualHost entries. Closes GH-1676.
|
8
|
+
* [Nginx] Fixes use of invalid logfile name (memory already released) in backup log redirection code. Possibly related to GH-1774.
|
9
|
+
* [Nginx] The preferred Nginx version is now 1.10.1 (previously 1.10.0).
|
10
|
+
* [Nginx] The preferred PCRE version is now 8.39 (previously 8.34).
|
11
|
+
* [Standalone] Passenger Standalone now supports /dev/stdout and /dev/stderr as log file path (via `--log-file` or Passengerfile.json). This is especially useful in Docker containers. In previous versions logging to those paths did not work, resulting in nothing getting logged at all.
|
12
|
+
|
13
|
+
|
1
14
|
Release 5.0.28
|
2
15
|
--------------
|
3
16
|
|
data/build/apache2.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Phusion Passenger - https://www.phusionpassenger.com/
|
2
|
-
# Copyright (c) 2010-
|
2
|
+
# Copyright (c) 2010-2016 Phusion Holding B.V.
|
3
3
|
#
|
4
4
|
# "Passenger", "Phusion Passenger" and "Union Station" are registered
|
5
5
|
# trademarks of Phusion Holding B.V.
|
@@ -128,11 +128,11 @@ end
|
|
128
128
|
|
129
129
|
def create_apache2_auto_generated_source_task(source)
|
130
130
|
dependencies = [
|
131
|
-
"#{source}.
|
131
|
+
"#{source}.cxxcodebuilder",
|
132
132
|
'src/ruby_supportlib/phusion_passenger/apache2/config_options.rb'
|
133
133
|
]
|
134
134
|
file(source => dependencies) do
|
135
|
-
template =
|
135
|
+
template = CxxCodeTemplateRenderer.new("#{source}.cxxcodebuilder")
|
136
136
|
template.render_to(source)
|
137
137
|
end
|
138
138
|
end
|
data/build/common_library.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
# Copyright (c) 2010-
|
3
|
+
# Copyright (c) 2010-2016 Phusion Holding B.V.
|
4
4
|
#
|
5
5
|
# "Passenger", "Phusion Passenger" and "Union Station" are registered
|
6
6
|
# trademarks of Phusion Holding B.V.
|
@@ -241,12 +241,12 @@ end
|
|
241
241
|
# If you add a new shared definition file, don't forget to update
|
242
242
|
# src/ruby_supportlib/phusion_passenger/packaging.rb!
|
243
243
|
|
244
|
-
dependencies = ['src/cxx_supportlib/Constants.h.
|
244
|
+
dependencies = ['src/cxx_supportlib/Constants.h.cxxcodebuilder',
|
245
245
|
'src/ruby_supportlib/phusion_passenger.rb',
|
246
246
|
'src/ruby_supportlib/phusion_passenger/constants.rb']
|
247
247
|
file 'src/cxx_supportlib/Constants.h' => dependencies do
|
248
248
|
PhusionPassenger.require_passenger_lib 'constants'
|
249
|
-
template =
|
249
|
+
template = CxxCodeTemplateRenderer.new('src/cxx_supportlib/Constants.h.cxxcodebuilder')
|
250
250
|
template.render_to('src/cxx_supportlib/Constants.h')
|
251
251
|
end
|
252
252
|
|
data/build/nginx.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Phusion Passenger - https://www.phusionpassenger.com/
|
2
|
-
# Copyright (c) 2010-
|
2
|
+
# Copyright (c) 2010-2016 Phusion Holding B.V.
|
3
3
|
#
|
4
4
|
# "Passenger", "Phusion Passenger" and "Union Station" are registered
|
5
5
|
# trademarks of Phusion Holding B.V.
|
@@ -27,7 +27,7 @@ auto_generated_sources = %w(
|
|
27
27
|
src/nginx_module/CreateLocationConfig.c
|
28
28
|
src/nginx_module/MergeLocationConfig.c
|
29
29
|
src/nginx_module/CacheLocationConfig.c
|
30
|
-
src/nginx_module/
|
30
|
+
src/nginx_module/LocationConfig.h
|
31
31
|
)
|
32
32
|
|
33
33
|
desc "Build Nginx support files"
|
@@ -70,11 +70,11 @@ end
|
|
70
70
|
|
71
71
|
def create_nginx_auto_generated_source_task(source)
|
72
72
|
dependencies = [
|
73
|
-
"#{source}.
|
73
|
+
"#{source}.cxxcodebuilder",
|
74
74
|
'src/ruby_supportlib/phusion_passenger/nginx/config_options.rb'
|
75
75
|
]
|
76
76
|
file(source => dependencies) do
|
77
|
-
template =
|
77
|
+
template = CxxCodeTemplateRenderer.new("#{source}.cxxcodebuilder")
|
78
78
|
template.render_to(source)
|
79
79
|
end
|
80
80
|
end
|
data/build/packaging.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Phusion Passenger - https://www.phusionpassenger.com/
|
2
|
-
# Copyright (c) 2010-
|
2
|
+
# Copyright (c) 2010-2016 Phusion Holding B.V.
|
3
3
|
#
|
4
4
|
# "Passenger", "Phusion Passenger" and "Union Station" are registered
|
5
5
|
# trademarks of Phusion Holding B.V.
|
@@ -206,7 +206,7 @@ task 'package:release' => ['package:set_official', 'package:gem', 'package:tarba
|
|
206
206
|
puts "HOMEBREW_DRY_RUN set, not submitting pull request. Please find the repo in /tmp/homebrew."
|
207
207
|
else
|
208
208
|
puts "Submitting Homebrew pull request..."
|
209
|
-
sh "cd #{homebrew_dir} && hub pull-request '
|
209
|
+
sh "cd #{homebrew_dir} && hub pull-request -m 'passenger #{version}' -b Homebrew:master"
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
@@ -332,12 +332,13 @@ task 'package:update_homebrew' do
|
|
332
332
|
sha256 = File.open("#{PKG_DIR}/passenger-#{version}.tar.gz", "rb") do |f|
|
333
333
|
Digest::SHA256.hexdigest(f.read)
|
334
334
|
end
|
335
|
-
|
336
|
-
|
337
|
-
|
335
|
+
if !File.exist?(homebrew_dir)
|
336
|
+
sh "git clone git@github.com:phusion/homebrew-core.git #{homebrew_dir}"
|
337
|
+
sh "cd #{homebrew_dir} && git remote add Homebrew https://github.com/Homebrew/homebrew-core.git"
|
338
|
+
end
|
338
339
|
sh "cd #{homebrew_dir} && git fetch Homebrew"
|
339
340
|
sh "cd #{homebrew_dir} && git reset --hard Homebrew/master"
|
340
|
-
formula = File.read("/tmp/homebrew/
|
341
|
+
formula = File.read("/tmp/homebrew/Formula/passenger.rb")
|
341
342
|
formula.gsub!(/passenger-.+?\.tar\.gz/, "passenger-#{version}.tar.gz") ||
|
342
343
|
abort("Unable to substitute Homebrew formula tarball filename")
|
343
344
|
formula.gsub!(/^ sha256 .*/, " sha256 \"#{sha256}\"") ||
|
@@ -348,13 +349,13 @@ task 'package:update_homebrew' do
|
|
348
349
|
necessary_dirs_str = word_wrap(necessary_dirs.inspect).split("\n").join("\n ")
|
349
350
|
formula.sub!(/necessary_files = .*?\]/m, "necessary_files = Dir#{necessary_dirs_str}") ||
|
350
351
|
abort("Unable to substitute file whitelist")
|
351
|
-
File.open("/tmp/homebrew/
|
352
|
+
File.open("/tmp/homebrew/Formula/passenger.rb", "w") do |f|
|
352
353
|
f.write(formula)
|
353
354
|
end
|
354
355
|
sh "cd #{homebrew_dir} && git commit -a -m 'passenger #{version}'"
|
355
356
|
sh "cd #{homebrew_dir} && git push -f"
|
356
357
|
if boolean_option('HOMEBREW_TEST', true)
|
357
|
-
sh "cp /tmp/homebrew/
|
358
|
+
sh "cp /tmp/homebrew/Formula/passenger.rb /usr/local/Library/Formula/passenger.rb"
|
358
359
|
if `brew info passenger` !~ /^Not installed$/
|
359
360
|
sh "brew uninstall passenger"
|
360
361
|
end
|
@@ -6237,7 +6237,9 @@ CXX_DEPENDENCY_MAP =
|
|
6237
6237
|
"src/cxx_supportlib/MemoryKit/mbuf.cpp"=>
|
6238
6238
|
["src/cxx_supportlib/Logging.h",
|
6239
6239
|
"src/cxx_supportlib/MemoryKit/mbuf.h",
|
6240
|
+
"src/cxx_supportlib/StaticString.h",
|
6240
6241
|
"src/cxx_supportlib/Utils/FastStringStream.h",
|
6242
|
+
"src/cxx_supportlib/Utils/StrIntUtils.h",
|
6241
6243
|
"src/cxx_supportlib/oxt/backtrace.hpp",
|
6242
6244
|
"src/cxx_supportlib/oxt/detail/../spin_lock.hpp",
|
6243
6245
|
"src/cxx_supportlib/oxt/detail/backtrace_disabled.hpp",
|
@@ -7406,16 +7408,14 @@ CXX_DEPENDENCY_MAP =
|
|
7406
7408
|
"src/nginx_module/CacheLocationConfig.c",
|
7407
7409
|
"src/nginx_module/Configuration.h",
|
7408
7410
|
"src/nginx_module/ConfigurationCommands.c",
|
7409
|
-
"src/nginx_module/ConfigurationFields.h",
|
7410
7411
|
"src/nginx_module/ContentHandler.h",
|
7411
7412
|
"src/nginx_module/CreateLocationConfig.c",
|
7413
|
+
"src/nginx_module/LocationConfig.h",
|
7412
7414
|
"src/nginx_module/MergeLocationConfig.c"],
|
7413
7415
|
"src/nginx_module/Configuration.h"=>
|
7414
|
-
["src/nginx_module/
|
7416
|
+
["src/nginx_module/LocationConfig.h"],
|
7415
7417
|
"src/nginx_module/ConfigurationCommands.c"=>
|
7416
7418
|
[],
|
7417
|
-
"src/nginx_module/ConfigurationFields.h"=>
|
7418
|
-
[],
|
7419
7419
|
"src/nginx_module/ContentHandler.c"=>
|
7420
7420
|
["src/cxx_supportlib/AppTypes.h",
|
7421
7421
|
"src/cxx_supportlib/Constants.h",
|
@@ -7442,8 +7442,8 @@ CXX_DEPENDENCY_MAP =
|
|
7442
7442
|
"src/cxx_supportlib/oxt/thread.hpp",
|
7443
7443
|
"src/cxx_supportlib/oxt/tracable_exception.hpp",
|
7444
7444
|
"src/nginx_module/Configuration.h",
|
7445
|
-
"src/nginx_module/ConfigurationFields.h",
|
7446
7445
|
"src/nginx_module/ContentHandler.h",
|
7446
|
+
"src/nginx_module/LocationConfig.h",
|
7447
7447
|
"src/nginx_module/StaticContentHandler.h"],
|
7448
7448
|
"src/nginx_module/ContentHandler.h"=>
|
7449
7449
|
["src/cxx_supportlib/AppTypes.h",
|
@@ -7471,6 +7471,8 @@ CXX_DEPENDENCY_MAP =
|
|
7471
7471
|
"src/cxx_supportlib/oxt/tracable_exception.hpp"],
|
7472
7472
|
"src/nginx_module/CreateLocationConfig.c"=>
|
7473
7473
|
[],
|
7474
|
+
"src/nginx_module/LocationConfig.h"=>
|
7475
|
+
[],
|
7474
7476
|
"src/nginx_module/MergeLocationConfig.c"=>
|
7475
7477
|
[],
|
7476
7478
|
"src/nginx_module/StaticContentHandler.c"=>
|
@@ -7503,8 +7505,8 @@ CXX_DEPENDENCY_MAP =
|
|
7503
7505
|
"src/cxx_supportlib/oxt/thread.hpp",
|
7504
7506
|
"src/cxx_supportlib/oxt/tracable_exception.hpp",
|
7505
7507
|
"src/nginx_module/Configuration.h",
|
7506
|
-
"src/nginx_module/
|
7507
|
-
"src/nginx_module/
|
7508
|
+
"src/nginx_module/ContentHandler.h",
|
7509
|
+
"src/nginx_module/LocationConfig.h"],
|
7508
7510
|
"src/nginx_module/ngx_http_passenger_module.h"=>
|
7509
7511
|
["src/cxx_supportlib/AppTypes.h",
|
7510
7512
|
"src/cxx_supportlib/Constants.h",
|
data/build/support/general.rb
CHANGED
@@ -48,6 +48,37 @@ class TemplateRenderer
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
class CxxCodeTemplateRenderer
|
52
|
+
def initialize(filename)
|
53
|
+
if !defined?(CxxCodeBuilder)
|
54
|
+
require 'build/support/vendor/cxxcodebuilder/lib/cxxcodebuilder'
|
55
|
+
end
|
56
|
+
code = File.open(filename, 'rb') do |f|
|
57
|
+
f.read
|
58
|
+
end
|
59
|
+
@builder = CxxCodeBuilder::Builder.new
|
60
|
+
@builder.instance_eval(code, filename)
|
61
|
+
end
|
62
|
+
|
63
|
+
def render
|
64
|
+
@builder.to_s
|
65
|
+
end
|
66
|
+
|
67
|
+
def render_to(filename)
|
68
|
+
puts "Creating #{filename}"
|
69
|
+
text = render
|
70
|
+
# When packaging, some timestamps may be modified. The user may not
|
71
|
+
# have write access to the source root (for example, when Passenger
|
72
|
+
# Standalone is compiling its runtime), so we only write to the file
|
73
|
+
# when necessary.
|
74
|
+
if !File.exist?(filename) || File.writable?(filename) || File.read(filename) != text
|
75
|
+
File.open(filename, 'w') do |f|
|
76
|
+
f.write(text)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
51
82
|
class Pathname
|
52
83
|
if !method_defined?(:/)
|
53
84
|
def /(other)
|
@@ -94,6 +125,14 @@ def maybe_wrap_in_ccache(command)
|
|
94
125
|
end
|
95
126
|
end
|
96
127
|
|
128
|
+
def copyright_header_for(filename)
|
129
|
+
contents = File.open(filename, 'rb') do |f|
|
130
|
+
f.read
|
131
|
+
end
|
132
|
+
contents =~ /\A(#.+?)\n\n/m
|
133
|
+
$1.gsub(/^# */, '')
|
134
|
+
end
|
135
|
+
|
97
136
|
def ensure_target_directory_exists(target)
|
98
137
|
dir = File.dirname(target)
|
99
138
|
if !File.exist?(dir)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.2.5)
|
5
|
+
rake (11.1.2)
|
6
|
+
rspec (3.4.0)
|
7
|
+
rspec-core (~> 3.4.0)
|
8
|
+
rspec-expectations (~> 3.4.0)
|
9
|
+
rspec-mocks (~> 3.4.0)
|
10
|
+
rspec-core (3.4.4)
|
11
|
+
rspec-support (~> 3.4.0)
|
12
|
+
rspec-expectations (3.4.0)
|
13
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
14
|
+
rspec-support (~> 3.4.0)
|
15
|
+
rspec-mocks (3.4.1)
|
16
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
17
|
+
rspec-support (~> 3.4.0)
|
18
|
+
rspec-support (3.4.1)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
rake
|
25
|
+
rspec
|
26
|
+
|
27
|
+
BUNDLED WITH
|
28
|
+
1.11.2
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2016 Phusion Holding B.V.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# cxxcodebuilder: generate C/C++ code with a Builder-style DSL
|
2
|
+
|
3
|
+
Cxxcodebuilder gives you a simple Ruby API for programmatically outputting C/C++ code with proper indenting and formatting. Code using this API is much more readable than code building raw strings. Cxxcodebuilder is similar to [Jbuilder](https://github.com/rails/jbuilder), which is for outputting JSON.
|
4
|
+
|
5
|
+
## Use cases
|
6
|
+
|
7
|
+
This library is useful in build systems for automatically generating C/C++ code. It is much cleaner compared to using ERB or other generic text templating systems for the job.
|
8
|
+
|
9
|
+
## Example
|
10
|
+
|
11
|
+
Suppose that you want to write the following piece of code:
|
12
|
+
|
13
|
+
~~~c++
|
14
|
+
#include <stdio.h>
|
15
|
+
|
16
|
+
static int limit = 0;
|
17
|
+
static int magicNumbers[] = [1, 2, 3];
|
18
|
+
static Foo foos[] = [
|
19
|
+
{ "hello", 1 },
|
20
|
+
{ "world", 2 }
|
21
|
+
];
|
22
|
+
|
23
|
+
/*
|
24
|
+
* This is an awesome model
|
25
|
+
* for a futuristic car.
|
26
|
+
*/
|
27
|
+
struct Car {
|
28
|
+
unsigned int seats;
|
29
|
+
};
|
30
|
+
|
31
|
+
static int
|
32
|
+
modifyLimit(int diff) {
|
33
|
+
int oldLimit = limit;
|
34
|
+
limit += diff;
|
35
|
+
printf("The new limit is: %s\n", limit);
|
36
|
+
return oldLimit;
|
37
|
+
}
|
38
|
+
~~~
|
39
|
+
|
40
|
+
Use Cxxcodebuilder as follows:
|
41
|
+
|
42
|
+
~~~ruby
|
43
|
+
require 'cxxcodebuilder'
|
44
|
+
|
45
|
+
builder = CxxCodeBuilder::Builder.new do
|
46
|
+
include '<stdio.h>'
|
47
|
+
|
48
|
+
separator
|
49
|
+
|
50
|
+
field 'static int limit', 0
|
51
|
+
|
52
|
+
field 'static int magicNumbers[]' do
|
53
|
+
array_initializer do
|
54
|
+
element 1
|
55
|
+
element 2
|
56
|
+
element 3
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
field 'static Foo foo[]' do
|
61
|
+
array_initializer do
|
62
|
+
struct_element do
|
63
|
+
string_element 'hello'
|
64
|
+
element 1
|
65
|
+
end
|
66
|
+
struct_element do
|
67
|
+
string_element 'world'
|
68
|
+
element 2
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
separator
|
74
|
+
|
75
|
+
comment %q{
|
76
|
+
This is an awesome model
|
77
|
+
for a futuristic car.
|
78
|
+
}
|
79
|
+
struct 'Car' do
|
80
|
+
field 'unsigned int seats'
|
81
|
+
end
|
82
|
+
|
83
|
+
separator
|
84
|
+
|
85
|
+
function('static int modifyLimit(int diff)', %q{
|
86
|
+
int oldLimit = limit;
|
87
|
+
limit += diff;
|
88
|
+
printf("The new limit is: %s\n", limit);
|
89
|
+
return oldLimit;
|
90
|
+
})
|
91
|
+
end
|
92
|
+
|
93
|
+
puts(builder)
|
94
|
+
~~~
|
95
|
+
|
96
|
+
## API
|
97
|
+
|
98
|
+
See the comments in lib/cxxcodebuilder/builder.rb for the full API.
|