Skip to content

Commit 4403362

Browse files
committed
Try to compile rust library inside container
1 parent cc51009 commit 4403362

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

.github/workflows/build-gems.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,9 @@ jobs:
7575
with:
7676
bundler-cache: false
7777

78-
- name: Set up Rust
79-
uses: dtolnay/rust-toolchain@stable
80-
with:
81-
toolchain: stable
82-
83-
- name: Build CSS Parser
84-
run: cd src/css && cargo build --release
85-
8678
- name: bundle install
8779
run: bundle install
8880

89-
- name: Render Templates
90-
run: bundle exec rake templates
91-
92-
- name: Compile Herb
93-
run: bundle exec rake make
94-
9581
- name: Build gem
9682
run: |
9783
if [ "${{ matrix.target }}" = "default" ]; then

Rakefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ begin
6262
sh "bundle config set cache_all true"
6363

6464
PLATFORMS.each do |platform|
65-
RakeCompilerDock.sh "bundle --local && rake native:#{platform} gem", platform: platform
65+
RakeCompilerDock.sh(
66+
"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && " \
67+
"source $HOME/.cargo/env && " \
68+
"bundle --local && rake native:#{platform} gem",
69+
platform: platform
70+
)
6671
end
6772

6873
RakeCompilerDock.sh "bundle --local && rake java gem", rubyvm: :jruby
@@ -95,6 +100,8 @@ begin
95100
desc "Build the native gem for #{platform}"
96101
task platform => "prepare" do
97102
RakeCompilerDock.sh(
103+
"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && " \
104+
"source $HOME/.cargo/env && " \
98105
"bundle --local && rake native:#{platform} gem RUBY_CC_VERSION='#{ENV.fetch("RUBY_CC_VERSION", nil)}'",
99106
platform: platform
100107
)

ext/herb/extconf.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44

55
Dir.chdir(File.expand_path("../..", __dir__)) do
66
system("rake templates", exception: true)
7+
8+
css_parser_path = "src/css"
9+
css_parser_lib = "#{css_parser_path}/target/release/libherb_css_parser.a"
10+
11+
unless File.exist?(css_parser_lib)
12+
puts "Building CSS parser with Rust..."
13+
unless system("cd #{css_parser_path} && cargo build --release")
14+
abort "Failed to build CSS parser. Make sure Rust and Cargo are installed."
15+
end
16+
else
17+
puts "CSS parser already built at #{css_parser_lib}"
18+
end
719
end
820

921
extension_name = "herb"

0 commit comments

Comments
 (0)