Skip to content

Commit

Permalink
[Truffle] Attempt at removing core from mx.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Dec 9, 2016
1 parent 5a948d5 commit 2b56607
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 128 deletions.
102 changes: 5 additions & 97 deletions mx.jruby/mx_jruby.py
Expand Up @@ -58,101 +58,6 @@ class LicensesProject(ArchiveProject):
def getResults(self):
return [join(_suite.dir, f) for f in self.license_files]

def mavenSetup():
maven_args = []
env = os.environ.copy()
if not mx.get_opts().verbose:
maven_args.append('-q')

buildPack = join(_suite.dir, 'jruby-build-pack/maven')
if isdir(buildPack):
maven_args.append('-Dmaven.repo.local=' + buildPack)
elif 'CI' in env and 'TRAVIS' not in env:
maven_args.append('-Dmaven.repo.local=' + join(_suite.dir, 'mxbuild/mvn'))

if not mx.get_opts().verbose:
env['JRUBY_BUILD_MORE_QUIET'] = 'true'
# HACK: since the maven executable plugin does not configure the
# java executable that is used we unfortunately need to prepend it to the PATH
javaHome = os.getenv('JAVA_HOME')
if javaHome:
env["PATH"] = javaHome + '/bin' + os.pathsep + env["PATH"]
mx.logv('Setting PATH to {}'.format(env["PATH"]))
mx.run(['java', '-version'], env=env)
return maven_args, env

class JRubyCoreMavenProject(mx.MavenProject):
def getBuildTask(self, args):
return JRubyCoreBuildTask(self, args, 1)

def getResults(self):
return None

def get_source_path(self, resolve):
with open(join(_suite.dir, 'VERSION')) as f:
version = f.readline().strip()
return join(_suite.dir, 'core/target/jruby-core-' + version + '-shaded-sources.jar')

class JRubyCoreBuildTask(mx.BuildTask):
def __str__(self):
return 'Building {} with Maven'.format(self.subject)

def newestOutput(self):
return TimeStampFile(join(_suite.dir, self.subject.jar))

def needsBuild(self, newestInput):
sup = mx.BuildTask.needsBuild(self, newestInput)
if sup[0]:
return sup

jar = self.newestOutput()

if not jar.exists():
return (True, 'no jar yet')

jni_libs = join(_suite.dir, 'lib/jni')
if not exists(jni_libs) or not os.listdir(jni_libs):
return (True, jni_libs)

bundler = join(_suite.dir, 'lib/ruby/gems/shared/gems/bundler-1.10.6')
if not exists(bundler) or not os.listdir(bundler):
return (True, bundler)

for watched in self.subject.watch:
watched = join(_suite.dir, watched)
if not exists(watched):
return (True, watched + ' does not exist')
elif os.path.isfile(watched) and TimeStampFile(watched).isNewerThan(jar):
return (True, watched + ' is newer than the jar')
else:
for root, _, files in os.walk(watched):
for name in files:
source = join(root, name)
if TimeStampFile(source).isNewerThan(jar):
return (True, source + ' is newer than the jar')

return (False, 'all files are up to date')

def build(self):
cwd = _suite.dir
maven_args, env = mavenSetup()
mx.log("Building jruby-core with Maven")
mx.run_maven(maven_args + ['-DskipTests', '-Dcreate.sources.jar', '-pl', 'core,lib'], cwd=cwd, env=env)
# Install Bundler
gem_home = join(_suite.dir, 'lib', 'ruby', 'gems', 'shared')
env['GEM_HOME'] = gem_home
env['GEM_PATH'] = gem_home
mx.run(['bin/jruby', 'bin/gem', 'install', 'bundler', '-v', '1.10.6'], cwd=cwd, env=env)

def clean(self, forBuild=False):
if forBuild:
return
maven_args, env = mavenSetup()
mx.run_maven(maven_args + ['clean'], nonZeroIsFatal=False, cwd=_suite.dir, env=env)
jar = self.newestOutput()
if jar.exists():
os.remove(jar.path)

# Commands

def extractArguments(cli_args):
Expand All @@ -161,7 +66,6 @@ def extractArguments(cli_args):
classpath = []
print_command = False
classic = False
main_class = "org.jruby.Main"

jruby_opts = os.environ.get('JRUBY_OPTS')
if jruby_opts:
Expand All @@ -171,7 +75,7 @@ def extractArguments(cli_args):
while args:
arg = args.pop(0)
if arg == '-X+T':
main_class = "org.jruby.truffle.Main"
classic = False
elif arg == '-Xclassic':
classic = True
elif arg == '-J-cmd':
Expand Down Expand Up @@ -203,6 +107,10 @@ def extractArguments(cli_args):
rubyArgs.append(arg)
rubyArgs.extend(args)
break
if classic:
main_class = "org.jruby.Main"
else:
main_class = "org.jruby.truffle.Main"
return vmArgs, rubyArgs, classpath, print_command, classic, main_class

def setup_jruby_home():
Expand Down
122 changes: 94 additions & 28 deletions mx.jruby/suite.py
Expand Up @@ -7,23 +7,34 @@
# GNU Lesser General Public License version 2.1

def mavenLib(mavenDep, sha1, sourceSha1, license):
groupId, artifactId, version = mavenDep.split(':')
args = (groupId.replace('.', '/'), artifactId, version, artifactId, version)
base = "https://search.maven.org/remotecontent?filepath=%s/%s/%s/%s-%s" % args
components = mavenDep.split(':')
if len(components) == 3:
groupId, artifactId, version = components
native = None
else:
groupId, artifactId, version, native = components
if native:
args = (groupId.replace('.', '/'), artifactId, version, artifactId, version, native)
base = "https://search.maven.org/remotecontent?filepath=%s/%s/%s/%s-%s-%s" % args
else:
args = (groupId.replace('.', '/'), artifactId, version, artifactId, version)
base = "https://search.maven.org/remotecontent?filepath=%s/%s/%s/%s-%s" % args
url = base + ".jar"
sourceUrl = base + '-sources.jar'
return {
description = {
"urls": [ url ],
"sha1": sha1,
"sourceUrls": [ sourceUrl ],
"sourceSha1": sourceSha1,
"maven": {
"groupId": groupId,
"artifactId": artifactId,
"version": version,
},
"license": license
}
if sourceSha1:
description["sourceUrls"] = [ sourceUrl ]
description["sourceSha1"] = sourceSha1
return description

suite = {
"mxversion": "5.59.0",
Expand Down Expand Up @@ -81,33 +92,101 @@ def mavenLib(mavenDep, sha1, sourceSha1, license):

# ------------- Libraries -------------

"ASM": mavenLib(
"org.ow2.asm:asm:5.0.4",
"0da08b8cce7bbf903602a25a3a163ae252435795",
"112ff54474f1f04ccf1384c92e39fdc566f0bb5e",
"BSD-new"),

"JNR_UNIXSOCKET": mavenLib(
"com.github.jnr:jnr-unixsocket:0.14",
"0943cc10ae00e9b6994f5419a85819d329e5656c",
"d03edf57d8052231e023203d10ace1da13447bd4",
"Apache-2.0"),

"JNR_POSIX": mavenLib(
"com.github.jnr:jnr-posix:3.0.32",
"a6fbbc386acbae4fd3d892f13e2141655ed6e9c0",
"7501075537354d9d9fa99f8b753c1f7844db0a45",
"EPL-1.0"),

"JNR_CONSTANTS": mavenLib(
"com.github.jnr:jnr-constants:0.9.6",
"84955256aa28919f12b6c7c9437ed65d814a3c0c",
"5579ab41c687085e714fc330536ec4dda3350b08",
"Apache-2.0"),

"JNR_FFI": mavenLib(
"com.github.jnr:jnr-ffi:2.1.1",
"ea33aabb52fa201adcf12cddd2f07260bc11e895",
"3243e30dd85d29758901c26d86aea434497cd696",
"Apache-2.0"),

"JFFI": mavenLib(
"com.github.jnr:jffi:1.2.13",
"8926bd0b2d0e9a46e7607eb7866356845c7df9a2",
"691ec868b9569092687553a8099a28f71f175097",
"Apache-2.0"),

"JFFI_NATIVE": mavenLib(
"com.github.jnr:jffi:1.2.13:native",
"c4b81ddacd1e94a73780aa6e4e8b9d2945d5eb4c",
None,
[ "Apache-2.0", "MIT" ]),

"SNAKEYAML": mavenLib(
"org.yaml:snakeyaml:1.14",
"c2df91929ed06a25001939929bff5120e0ea3fd4",
"4c6bcedc3efa772a5ae1c2fd01efee8e4d15edac",
"Apache-2.0"),

"JONI": mavenLib(
"org.jruby.joni:joni:2.1.11",
"655cc3aba1bc9dbdd653f28937bec16f3e9c4cec",
"2982d6beb2f8fabe5ac5cc9dec6b4d6a9ffeedb1",
"MIT"),

"BYTELIST": mavenLib(
"org.jruby.extras:bytelist:1.0.13",
"dc54989113128bda0d303c7bf97a7aba65507ddf",
"e8f683aa496bf651879d9e3a8a82e053c2df9b99",
"EPL-1.0"),

"JCODINGS": mavenLib(
"org.jruby.jcodings:jcodings:1.0.18",
"e2c76a19f00128bb1806207e2989139bfb45f49d",
"201985f0f15af95f03494ab9ef0400e849090d6c",
"MIT"),

"JODA_TIME": mavenLib(
"joda-time:joda-time:2.8.2",
"d27c24204c5e507b16fec01006b3d0f1ec42aed4",
"65dd2b998571ea61a3cee68c99a1dde729b14a7e",
"Apache-2.0"),
},

"projects": {

# ------------- Projects -------------

"jruby-core": {
"class": "JRubyCoreMavenProject",
"sourceDirs": [ "core/src/main/java" ],
"watch": [ "core/src", "core/pom.rb" ],
"jar": "lib/jruby.jar",
"license": [ "EPL-1.0", "BSD-new", "BSD-simplified", "MIT", "Apache-2.0" ],
},

"jruby-truffle": {
"dir": "truffle/src/main",
"sourceDirs": [ "java" ],
"dependencies": [
"jruby-core",
"truffle:TRUFFLE_API",
"truffle:TRUFFLE_DEBUG",
"ASM",
"JNR_UNIXSOCKET",
"JNR_POSIX",
"JNR_CONSTANTS",
"JNR_FFI",
"JFFI",
"JFFI_NATIVE",
"SNAKEYAML",
"JONI",
"BYTELIST",
"JCODINGS",
"JODA_TIME",
],
"annotationProcessors": ["truffle:TRUFFLE_DSL_PROCESSOR"],
"javaCompliance": "1.8",
Expand Down Expand Up @@ -143,21 +222,10 @@ def mavenLib(mavenDep, sha1, sourceSha1, license):
"license": "EPL-1.0",
},

# Depends on jruby-core extracting jni libs in lib/jni
"jruby-lib-jni": {
"class": "ArchiveProject",
"outputDir": "lib/jni",
"prefix": "lib/jni",
"dependencies": [ "jruby-core" ],
"license": [ "Apache-2.0", "MIT" ],
},

# Depends on jruby-core installing gems in lib/ruby
"jruby-lib-ruby": {
"class": "ArchiveProject",
"outputDir": "lib/ruby",
"prefix": "lib/ruby",
"dependencies": [ "jruby-core" ],
"license": [ "EPL-1.0", "MIT", "BSD-simplified", "GPLv2", "LGPLv21", "zlib" ],
},

Expand All @@ -175,7 +243,6 @@ def mavenLib(mavenDep, sha1, sourceSha1, license):
"RUBY": {
"mainClass": "org.jruby.Main",
"dependencies": [
"jruby-core",
"jruby-truffle",
"jruby-truffle-ruby",
],
Expand All @@ -195,7 +262,6 @@ def mavenLib(mavenDep, sha1, sourceSha1, license):
"native": True, # Not Java
"relpath": True,
"dependencies": [
"jruby-lib-jni",
"jruby-lib-ruby",
"jruby-licenses",
],
Expand Down
3 changes: 1 addition & 2 deletions tool/jt.rb
Expand Up @@ -149,8 +149,7 @@ def self.find_sl

def self.mx?
mx_ruby_jar = "#{JRUBY_DIR}/mxbuild/dists/ruby.jar"
constants_file = "#{JRUBY_DIR}/core/src/main/java/org/jruby/runtime/Constants.java"
File.exist?(mx_ruby_jar) && File.mtime(mx_ruby_jar) >= File.mtime(constants_file)
File.exist?(mx_ruby_jar)
end

def self.find_ruby
Expand Down
2 changes: 1 addition & 1 deletion truffle/pom.rb
Expand Up @@ -22,7 +22,7 @@
jar 'com.oracle.truffle:truffle-debug:' + truffle_version
jar 'com.oracle.truffle:truffle-dsl-processor:' + truffle_version, :scope => 'provided'
jar 'com.oracle.truffle:truffle-tck:' + truffle_version, :scope => 'test'

jar 'com.github.jnr:jnr-unixsocket:0.14'
jar 'com.github.jnr:jnr-posix:3.0.32'
jar 'com.github.jnr:jnr-constants:0.9.6'
Expand Down

0 comments on commit 2b56607

Please sign in to comment.