Skip to content

Commit f39ef4d

Browse files
committed
Build YARP using configure and its Makefile
1 parent e6bee4f commit f39ef4d

File tree

5 files changed

+48
-10
lines changed

5 files changed

+48
-10
lines changed

mx.truffleruby/mx_truffleruby.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,24 @@ def contents(self, result):
121121
command = [jdk.java] + jvm_args + [main_class] + ruby_options + ['"$@"']
122122
return "#!/usr/bin/env bash\n" + "exec " + " ".join(command) + "\n"
123123

124+
125+
class YARPNativeProject(mx.NativeProject):
126+
def __init__(self, suite, name, deps, workingSets, output=None, **kwArgs):
127+
path = join(root, kwArgs.pop('dir'))
128+
super(YARPNativeProject, self).__init__(
129+
suite, name, subDir=None, srcDirs=[path], deps=deps, workingSets=workingSets,
130+
results=kwArgs.pop('results'),
131+
output=path, d=path, vpath=False, **kwArgs)
132+
133+
def getBuildTask(self, args):
134+
return YARPNativeBuildTask(args, self)
135+
136+
class YARPNativeBuildTask(mx.NativeBuildTask):
137+
def build(self):
138+
mx.run(['autoreconf'], cwd=self.subject.dir)
139+
mx.run(['./configure'], cwd=self.subject.dir)
140+
super(YARPNativeBuildTask, self).build() # make
141+
124142
# Commands
125143

126144
def jt(*args):

mx.truffleruby/suite.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,26 @@
204204
},
205205

206206
"org.yarp.libyarp": {
207+
"class": "YARPNativeProject",
207208
"dir": "src/main/c/yarp",
209+
"makeTarget": "all-no-debug", # Comment this out to build with asserts and no optimizations
210+
"results": ["build/librubyparser.a"],
211+
"description": "YARP used as a static library"
212+
},
213+
214+
"org.truffleruby.yarp.bindings": {
215+
"dir": "src/main/c/yarp_bindings",
208216
"native": "shared_lib",
209217
"deliverable": "yarp",
210218
"buildDependencies": [
219+
"org.yarp.libyarp", # librubyparser.a
211220
"org.yarp", # for the generated JNI header file
212221
],
213222
"use_jdk_headers": True, # the generated JNI header includes jni.h
214-
"cflags": ["-g", "-Wall", "-Werror", "-pthread"],
223+
"cflags": ["-g", "-Wall", "-Werror", "-pthread", "-I<path:org.yarp.libyarp>/include"],
215224
"ldflags": ["-pthread"],
216-
"description": "YARP + JNI bindings as a single lib"
225+
"ldlibs": ["<path:org.yarp.libyarp>/build/librubyparser.a"],
226+
"description": "JNI bindings for YARP"
217227
},
218228

219229
"org.truffleruby": {
@@ -485,7 +495,7 @@
485495
"file:lib/mri",
486496
"file:lib/patches",
487497
"file:lib/truffle",
488-
"dependency:org.yarp.libyarp",
498+
"dependency:org.truffleruby.yarp.bindings",
489499
],
490500
"lib/cext/": [
491501
"file:lib/cext/*.rb",

src/main/c/yarp/LICENSE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2022-present, Shopify Inc.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

tool/import-yarp.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33
set -x
44
set -e
55

6+
YARP=../../yarp
7+
68
# Create generated files
7-
pushd ../../yarp
9+
pushd $YARP
10+
bundle
11+
bundle exec rake clobber
812
bundle exec rake templates
913
popd
1014

11-
rm -rf src/main/c/yarp/src/yarp
12-
# Copy under src/yarp and not just src/ because we also have yarp_bindings.c
13-
mkdir src/main/c/yarp/src/yarp
14-
cp -R ../../yarp/include src/main/c/yarp/src/yarp
15-
cp -R ../../yarp/src src/main/c/yarp/src/yarp
15+
rm -rf src/main/c/yarp
16+
mkdir src/main/c/yarp
17+
cp -R $YARP/{include,src} src/main/c/yarp
18+
cp $YARP/{configure.ac,LICENSE.md,Makefile.in} src/main/c/yarp
1619

1720
rm -rf src/yarp/java
18-
cp -R ../../yarp/java src/yarp/java
21+
cp -R $YARP/java src/yarp/java

0 commit comments

Comments
 (0)