[38683] trunk/base/src/port1.0/resources/group

febeling at macports.org febeling at macports.org
Mon Jul 28 14:21:33 PDT 2008


Revision: 38683
          http://trac.macosforge.org/projects/macports/changeset/38683
Author:   febeling at macports.org
Date:     2008-07-28 14:21:33 -0700 (Mon, 28 Jul 2008)
Log Message:
-----------
Support for ruby19 ports in the ruby port group.

The command ruby.setup accepts an new optional
parameter "implementation", which is ruby18 by
default, and can also be ruby19. (As more ruby
implementations appear these may be added as
well.) Unit tests are in the new sub-directory
tests/.

Modified Paths:
--------------
    trunk/base/src/port1.0/resources/group/Makefile
    trunk/base/src/port1.0/resources/group/ruby-1.0.tcl

Added Paths:
-----------
    trunk/base/src/port1.0/resources/group/tests/
    trunk/base/src/port1.0/resources/group/tests/ruby-1.0.tcl

Modified: trunk/base/src/port1.0/resources/group/Makefile
===================================================================
--- trunk/base/src/port1.0/resources/group/Makefile	2008-07-28 19:54:02 UTC (rev 38682)
+++ trunk/base/src/port1.0/resources/group/Makefile	2008-07-28 21:21:33 UTC (rev 38683)
@@ -12,6 +12,7 @@
 distclean:
 
 test:
+	${TCLSH} tests/ruby-1.0.tcl
 
 install:
 	$(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m ${DSTMODE} ${INSTALLDIR}

Modified: trunk/base/src/port1.0/resources/group/ruby-1.0.tcl
===================================================================
--- trunk/base/src/port1.0/resources/group/ruby-1.0.tcl	2008-07-28 19:54:02 UTC (rev 38682)
+++ trunk/base/src/port1.0/resources/group/ruby-1.0.tcl	2008-07-28 21:21:33 UTC (rev 38683)
@@ -31,11 +31,14 @@
 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# Set some variables.
-set ruby.bin	${prefix}/bin/ruby
-set ruby.rdoc	${prefix}/bin/rdoc
 
+# Define these variables assuming ruby1.8 to make them accessible in
+# the portfile after port group declaration. They can be modified by
+# ruby.setup, e.g. to use another ruby than 1.8.
+set ruby.bin	        ${prefix}/bin/ruby
+set ruby.rdoc	        ${prefix}/bin/rdoc
+set ruby.gem            ${prefix}/bin/gem
+
 proc ruby.extract_config {var {default ""}} {
 	global ruby.bin
 	if {[catch {set val [exec ${ruby.bin} -e "require 'rbconfig';puts Config::CONFIG\[\"${var}\"\]"]}]} {
@@ -51,19 +54,40 @@
 set ruby.lib		[ruby.extract_config vendorlibdir ${prefix}/lib/ruby/vendor_ruby/${ruby.version}]
 set ruby.archlib	[ruby.extract_config vendorarchdir ${ruby.lib}/${ruby.arch}]
 
-# define these empty initially, they are set by ruby.setup arguments
 set ruby.module		""
 set ruby.filename	""
 set ruby.project	""
 set ruby.docs		{}
 set ruby.srcdir		""
 
-# ruby group setup procedure
-proc ruby.setup {module vers {type "install.rb"} {docs {}} {source "custom"}} {
-	global destroot prefix worksrcpath
-	global ruby.bin ruby.lib
-	global ruby.module ruby.project ruby.filename ruby.docs ruby.srcdir
+# ruby group setup procedure; optional for ruby 1.8 if you want only
+# basic variables, like ruby.lib and ruby.archlib.
+proc ruby.setup {module vers {type "install.rb"} {docs {}} {source "custom"} {implementation "ruby"}} {
+	global destroot prefix worksrcpath os.platform
+	global ruby.bin ruby.rdoc ruby.gem
+	global ruby.version 
+	global ruby.lib ruby.archlib
+	global ruby.module ruby.filename ruby.project ruby.docs ruby.srcdir
 
+	if {${implementation} eq "ruby19"} {
+		set ruby.bin	${prefix}/bin/ruby1.9
+		set ruby.rdoc	${prefix}/bin/rdoc1.9
+		set ruby.gem    ${prefix}/bin/gem1.9
+		set ruby.port_prefix rb19
+	} elseif {${implementation} eq "ruby"} {
+		# ruby.bin, ruby.rdoc, and ruby.gem set to 1.8 by default
+		set ruby.port_prefix rb
+	} else {
+		ui_error "ruby.setup: unknown implementation '${implementation}' specified (ruby, ruby19 possible)"
+		return -code error "ruby.setup failed"
+	}
+
+	# re-define variables to pick up possible implemantation change
+	set ruby.version	[ruby.extract_config ruby_version]
+	set ruby.arch		[ruby.extract_config arch ${os.platform}]
+	set ruby.lib		[ruby.extract_config vendorlibdir ${prefix}/lib/ruby/vendor_ruby/${ruby.version}]
+	set ruby.archlib	[ruby.extract_config vendorarchdir ${ruby.lib}/${ruby.arch}]
+
 	# define ruby global names and lists
 	# check if module is a list or string
 	if {[llength ${module}] > 1} {
@@ -80,7 +104,7 @@
 	}
 	set ruby.docs	${docs}
 
-	name			rb-[string tolower ${ruby.module}]
+	name			${ruby.port_prefix}-[string tolower ${ruby.module}]
 	version			${vers}
 	categories		ruby
 
@@ -131,7 +155,7 @@
 	distname		${ruby.filename}-${vers}
 	dist_subdir		ruby
 
-	depends_lib		path:${ruby.bin}:ruby
+	depends_lib		port:${implementation}
 
 	post-extract {
 		# Create the work directory for gem-based ruby ports.
@@ -275,7 +299,7 @@
 			}
 			
 			destroot {
-			  system "cd ${worksrcpath} && ${prefix}/bin/gem install --local --force --install-dir ${destroot}${prefix}/lib/ruby/gems/${ruby.version} ${distpath}/${distname}"
+			  system "cd ${worksrcpath} && ${ruby.gem} install --local --force --install-dir ${destroot}${prefix}/lib/ruby/gems/${ruby.version} ${distpath}/${distname}"
 			
 				set binDir ${destroot}${prefix}/lib/ruby/gems/${ruby.version}/bin
 				if {[file isdirectory $binDir]} {

Added: trunk/base/src/port1.0/resources/group/tests/ruby-1.0.tcl
===================================================================
--- trunk/base/src/port1.0/resources/group/tests/ruby-1.0.tcl	                        (rev 0)
+++ trunk/base/src/port1.0/resources/group/tests/ruby-1.0.tcl	2008-07-28 21:21:33 UTC (rev 38683)
@@ -0,0 +1,148 @@
+#!/bin/sh 
+# start as tcl \
+exec tclsh "$0" "$@"
+
+set prefix                    /opt/local
+set os.platform               i686-darwin
+
+# mock the commands the ruby group uses
+proc name p0                  {
+	global name.found
+	set name.found $p0
+}
+proc version p0               {
+	global version.found
+	set version.found $p0
+}
+proc categories p0	      {}
+proc distname p0	      {}
+proc dist_subdir p0	      {}
+proc depends_lib p0	      {
+	global depends_lib.found
+	set depends_lib.found $p0
+}
+proc post-extract p0	      {}
+proc configure.cmd {p0 p1 p2} {}
+proc configure.pre_args p0    {}
+proc build.target p0	      {
+	global build.target.found
+	set build.target.found $p0
+}
+proc build.cmd {p0 p1 p2}     {}
+proc pre-destroot p0	      {}
+proc destroot.cmd {p0 p1 p2}  {}
+proc destroot.target p0	      {}
+proc destroot.destdir {}      {}
+proc post-destroot p0	      {}
+
+proc use_configure p0	      {}
+proc extract.suffix p0	      {}
+proc depends_lib-append p0    {}
+proc extract p0		      {}
+proc build p0		      {}
+proc destroot p0	      {}
+
+# directory which contains test file
+set testdir [file dirname ${argv0}]
+
+namespace eval tests {
+	# Backwards compatible behaviour, assumes ruby1.8
+	proc test_rubysetup_ruby18_default {} {
+		global ruby.bin
+		global ruby.version
+		global ruby.module
+		global ruby.project
+		global ruby.filename 
+		global ruby.docs
+		global ruby.lib ruby.archlib
+
+		global build.target.found
+		global name.found
+		global version.found
+		global depends_lib.found
+
+		ruby.setup {test_module tmod} 9.9 setup.rb {README INSTALL}
+
+		if {"1.8" ne ${ruby.version}} { error "ruby.version failed: ${ruby.version}" }
+		if {"test_module" ne ${ruby.module}} { error "ruby.module failed" }
+		if {"tmod" ne ${ruby.project}} { error "ruby.project failed" }
+		if {"tmod" ne ${ruby.filename}} { error "ruby.filename failed" }
+		if {{README INSTALL} ne ${ruby.docs}} { error "ruby.docs failed"}
+		if {"setup" ne ${build.target.found}} { error "type-derived field build.target failed: ${build.target.found}"}
+		if {"rb-test_module" ne ${name.found}} { error "drived name failed: ${name.found}" }
+		if {"9.9" ne ${version.found}} { error "port version set failed" }
+		if {"port:ruby" ne ${depends_lib.found}} { error "depends_lib failed: ${depends_lib.found}" }
+
+		if {"/opt/local/lib/ruby/vendor_ruby/1.8" ne ${ruby.lib}} { error "ruby.lib failed: ${ruby.lib}" }
+		if {!(0 == [string first "/opt/local/lib/ruby/vendor_ruby/1.8/i686-darwin" ${ruby.archlib}])} { error "ruby.archlib failed: ${ruby.archlib}" }
+	}
+
+	proc test_rubysetup_type_gem {} {
+		if {[catch {ruby.setup {test_module tmod} 9.9 gem {README INSTALL}}]} {
+			error "gem type port fails"
+		}
+	}
+
+	proc test_rubysetup_ruby19 {} {
+		global ruby.version
+		global ruby.module
+		global ruby.project
+		global ruby.filename 
+		global ruby.bin
+		global ruby.docs
+		global ruby.lib ruby.archlib
+
+		global build.target.found
+		global name.found
+		global version.found
+		global depends_lib.found
+
+		ruby.setup {test_module tmod} 9.9 setup.rb {README INSTALL} custom ruby19
+
+		# changed prefix
+		if {![string equal "1.9.0" ${ruby.version}]} { error "ruby.version failed: '${ruby.version}'" }
+		if {![string equal "rb19-test_module" ${name.found}]} { error "drived name failed: ${name.found}" }
+
+		if {![string equal "test_module" ${ruby.module}]} { error "ruby.module failed" }
+		if {![string equal "tmod" ${ruby.project}]} { error "ruby.project failed" }
+		if {![string equal "tmod" ${ruby.filename}]} { error "ruby.filename failed" }
+		if {![string equal {README INSTALL} ${ruby.docs}]} { error "ruby.docs failed"}
+		if {![string equal "setup" ${build.target.found}]} { error "type-derived field failed: ${build.target.found}"}
+		if {![string equal "9.9" ${version.found}]} { error "port version set failed" }
+		if {![string equal "port:ruby19" ${depends_lib.found}]} { error "depends_lib failed: ${depends_lib.found}" }
+
+		if {![string equal "/opt/local/lib/ruby/vendor_ruby/1.9.0" ${ruby.lib}]} { error "ruby.lib failed: ${ruby.lib}" }
+		if {!(0 == [string first "/opt/local/lib/ruby/vendor_ruby/1.9.0/i686-darwin" ${ruby.archlib}])} { error "ruby.archlib failed: ${ruby.archlib}" }
+	}
+
+	proc test_setup_implementation_specifics {} {
+		if {![catch {ruby.setup {test_module tmod} 9.9 setup.rb {README INSTALL} custom "rubz"}]} {
+			error "wrong implementation name signals error"
+		}
+	}
+
+	proc test_variables_exported_without_rubysetup_call {} {
+		global prefix
+		global ruby.bin ruby.rdoc ruby.gem
+		global ruby.version ruby.arch ruby.lib ruby.archlib
+		if {"${prefix}/bin/ruby" ne ${ruby.bin}} { error "variable ruby.bin missing" }
+		if {"${prefix}/bin/rdoc" ne ${ruby.rdoc}} { error "variable ruby.rdoc missing" }
+		if {"${prefix}/bin/gem" ne ${ruby.gem}} { error "variable ruby.gem missing" }
+		if {"1.8" ne ${ruby.version}} { error "variable ruby.version missing" }
+		if {"i686-darwin9" ne ${ruby.arch}} { error "variable ruby.arch missing" }
+		if {"${prefix}/lib/ruby/vendor_ruby/1.8" ne ${ruby.lib}} { error "variable ruby.lib missing" }
+		if {"${prefix}/lib/ruby/vendor_ruby/1.8/i686-darwin9" ne${ruby.archlib}} { error "variable ruby.archlib missing" }
+	}
+	
+	# run all tests
+	if {![file executable $prefix/bin/ruby]} {
+		puts "WARNING: No ruby found, can't run ruby port group tests without installed ruby port; skipping."
+	} else {
+		foreach test [info procs test_*] { 
+			# evaluate port group file in global context 
+			# to reset global variables
+			uplevel {source "${testdir}/../ruby-1.0.tcl"}
+			$test
+		}
+	}
+}


Property changes on: trunk/base/src/port1.0/resources/group/tests/ruby-1.0.tcl
___________________________________________________________________
Name: svn:executable
   + *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080728/fb1f2c8a/attachment.html 


More information about the macports-changes mailing list