[Rcpp-commits] r398 - in pkg: R inst inst/discovery inst/skeleton

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jan 18 09:22:23 CET 2010


Author: romain
Date: 2010-01-18 09:22:22 +0100 (Mon, 18 Jan 2010)
New Revision: 398

Added:
   pkg/inst/discovery/cxx0x.R
Removed:
   pkg/inst/discovery/README
   pkg/inst/discovery/cxx0x.c
Modified:
   pkg/R/RcppLdpath.R
   pkg/inst/ChangeLog
   pkg/inst/skeleton/Makevars
Log:
replacing cxx0x.c by cxx0x.R so that it takes care of compiling and calling the code

Modified: pkg/R/RcppLdpath.R
===================================================================
--- pkg/R/RcppLdpath.R	2010-01-18 04:25:04 UTC (rev 397)
+++ pkg/R/RcppLdpath.R	2010-01-18 08:22:22 UTC (rev 398)
@@ -47,19 +47,9 @@
 # compile, load and call the cxx0x.c script to identify whether
 # the compiler is GCC >= 4.3
 RcppCxx0xFlags <- function(){
-	td <- tempfile()
-	dir.create( td )
-	here <- getwd()
-	setwd(td)
-	on.exit( { setwd(here) ; unlink( td, recursive = TRUE ) } )
-	file.copy( system.file( "discovery", "cxx0x.c", package = "Rcpp" ), td )
-        cmd <- paste(R.home(component="bin"), "/R CMD SHLIB cxx0x.c", sep="")
-	system( cmd, intern = TRUE )
-	dll <- sprintf( "cxx0x%s", .Platform$dynlib.ext )
-	dyn.load( dll )
-	res <- tryCatch( .Call( "cxx0x" ), error = "" )
-	dyn.unload( dll )
-	res
+	script <- system.file( "discovery", "cxx0x.R", package = "Rcpp" ) 
+	flag <- capture.output( source( script ) )
+	flag
 }
 
 Cxx0xFlags <- function() cat( RcppCxx0xFlags() )

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2010-01-18 04:25:04 UTC (rev 397)
+++ pkg/inst/ChangeLog	2010-01-18 08:22:22 UTC (rev 398)
@@ -1,5 +1,10 @@
-2010-01-16  Romain Francois <francoisromain at free.fr>
+2010-01-18  Romain Francois <francoisromain at free.fr>
 
+	* inst/discovery/cxx0x.R: replaces the cxx0x.c file to take 
+	care of compiling, etc...
+
+2010-01-17  Romain Francois <francoisromain at free.fr>
+
 	* src/exceptions.cpp: slightly less dumb exception logic 
 	on non GCC compilers. exceptions will now trigger an R error
 	with a default message (we don't attempt to get the 

Deleted: pkg/inst/discovery/README
===================================================================
--- pkg/inst/discovery/README	2010-01-18 04:25:04 UTC (rev 397)
+++ pkg/inst/discovery/README	2010-01-18 08:22:22 UTC (rev 398)
@@ -1,7 +0,0 @@
-The cxx0x.c script is used by the Rcpp::RcppCxx0xFlags function. 
-When called, the RcppCxx0xFlags compiles and loads this script, and then 
-calls the cxx0x function. 
-
-If compiled with GCC > 4.3 the script returns "-std=c++0x", otherwise
-it returns ""
-

Added: pkg/inst/discovery/cxx0x.R
===================================================================
--- pkg/inst/discovery/cxx0x.R	                        (rev 0)
+++ pkg/inst/discovery/cxx0x.R	2010-01-18 08:22:22 UTC (rev 398)
@@ -0,0 +1,59 @@
+#!/bin/env Rscript
+
+# Copyright (C) 2010	Dirk Eddelbuettel and Romain Francois
+#
+# This file is part of Rcpp.
+#
+# Rcpp is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# Rcpp is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
+
+# This script is used by the Rcpp::RcppCxx0xFlags function to
+# generate the "-std=c++0x" flag when the compiler in use is GCC >= 4.3
+
+local({
+	cxx0x.code <- '
+	#include <R.h>
+	#include <Rdefines.h>
+	
+	SEXP cxx0x(){
+	
+	#ifdef __GNUC__
+		#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+		#if GCC_VERSION >= 40300
+		return mkString( "-std=c++0x" ) ;
+		#endif
+	#endif
+	return mkString( "" ) ;
+	}
+	'
+	flag <- function(){
+		td <- tempfile()
+		dir.create( td )
+		here <- getwd()
+		setwd(td)
+		dll <- sprintf( "cxx0x%s", .Platform$dynlib.ext )
+		on.exit( { 
+			dyn.unload( dll )
+			setwd(here) ; 
+			unlink( td, recursive = TRUE )
+		} )
+		writeLines( cxx0x.code, "cxx0x.c" )
+		cmd <- sprintf( "%s/R CMD SHLIB cxx0x.c", R.home(component="bin") )
+		system( cmd, intern = TRUE )
+		dyn.load( dll )
+		res <- tryCatch( .Call( "cxx0x" ), error = "" )
+		res
+	}
+	cat( flag() )
+})
+

Deleted: pkg/inst/discovery/cxx0x.c
===================================================================
--- pkg/inst/discovery/cxx0x.c	2010-01-18 04:25:04 UTC (rev 397)
+++ pkg/inst/discovery/cxx0x.c	2010-01-18 08:22:22 UTC (rev 398)
@@ -1,14 +0,0 @@
-#include <R.h>
-#include <Rdefines.h>
-
-SEXP cxx0x(){
-
-#ifdef __GNUC__
-	#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
-	#if GCC_VERSION >= 40300
-	return mkString( "-std=c++0x" ) ;
-	#endif
-#endif
-return mkString( "" ) ;
-}
-

Modified: pkg/inst/skeleton/Makevars
===================================================================
--- pkg/inst/skeleton/Makevars	2010-01-18 04:25:04 UTC (rev 397)
+++ pkg/inst/skeleton/Makevars	2010-01-18 08:22:22 UTC (rev 398)
@@ -1,9 +1,5 @@
 PKG_CPPFLAGS=$(shell Rscript -e "Rcpp:::CxxFlags()" )
 PKG_LIBS = $(shell Rscript -e "Rcpp:::LdFlags()" )
-
 ## If C++0x features are desired, uncomment the next lines
 # PKG_CXXFLAGS += $(shell Rscript -e "Rcpp:::Cxx0xFlags()" )
-# all: $(SHLIB) hack
-# hack:
-# 	mkdir tmp; cp $(SHLIB) tmp/ ; rm -fr tmp
 



More information about the Rcpp-commits mailing list