2012-01-29 51 views
3

我正在閱讀emscripten的教程 - https://github.com/kripken/emscripten/wiki/Tutorial以及在本地計算機上查看源代碼中的一些演示項目。使用emscripten生成python.cc.js

到目前爲止,我已經下載了源代碼並正確設置了我的.emscripten設置文件。

我在尋找一個參考找出:爲了創建/輸出「python.cc.js」和「python.html」,需要什麼系列的emcc命令?感謝以前嘗試使用emscripten的開發人員的任何提示。

這是我的.emscripten文件:

EMSCRIPTEN_ROOT = os.path.expanduser('~/Dev/emscripten') # this helps projects using emscripten find it 

# LLVM_ROOT = os.path.expanduser('~/Dev/llvm-3.0/cbuild/bin') 
LLVM_ROOT = os.path.expanduser('/opt/local/bin') 

# See below for notes on which JS engine(s) you need 
NODE_JS = 'node' 
SPIDERMONKEY_ENGINE = [os.path.expanduser('~/Dev/mozilla-central/js/src/js'), '-m', '-n'] 
V8_ENGINE = os.path.expanduser('~/Dev/v8/d8') 

CLOSURE_COMPILER = os.path.expanduser('~/work/closure-compiler/compiler.jar') # optional (needed for the benchmarks) 

TEMP_DIR = '/tmp' 


######################################################################################################## 


# Pick the JS engine to use for running the compiler. This engine must exist, or 
# nothing can be compiled. 
# 
# Recommendation: If you already have node installed, use that. Otherwise, build v8 or 
#     spidermonkey from source. Any of these three is fine, as long as it's 
#     a recent version (especially for v8 and spidermonkey). 

COMPILER_ENGINE = NODE_JS 
#COMPILER_ENGINE = V8_ENGINE 
#COMPILER_ENGINE = SPIDERMONKEY_ENGINE 


# All JS engines to use when running the automatic tests. Not all the engines in this list 
# must exist (if they don't, they will be skipped in the test runner). 
# 
# Recommendation: If you already have node installed, use that. If you can, also build 
#     spidermonkey from source as well to get more test coverage (node can't 
#     run all the tests due to node issue 1669). v8 is currently not recommended 
#     here because of v8 issue 1822. 

JS_ENGINES = [NODE_JS, SPIDERMONKEY_ENGINE] 

而這裏的,我運行了emconfigure ./configure命令:

calvins-MacBook ttys000 Sun Feb 05 11:47:32 |~/community/Python-2.7.2| 
calvin$ emconfigure ./configure 
checking for --enable-universalsdk... no 
checking for --with-universal-archs... 32-bit 
checking MACHDEP... darwin 
checking EXTRAPLATDIR... $(PLATMACDIRS) 
checking machine type as reported by uname -m... x86_64 
checking for --without-gcc... no 
checking for gcc... /Users/calvin/work/emscripten/emcc 
checking whether the C compiler works... no 
configure: error: in `/Users/calvin/community/Python-2.7.2': 
configure: error: C compiler cannot create executables 
See `config.log' for more details 

這是造成的config.log:

This file contains any messages produced by compilers while 
running configure, to aid debugging if configure makes a mistake. 

It was created by python configure 2.7, which was 
generated by GNU Autoconf 2.68. Invocation command line was 

    $ ./configure 

## --------- ## 
## Platform. ## 
## --------- ## 

hostname = calvins-MacBook.local 
uname -m = x86_64 
uname -r = 11.2.0 
uname -s = Darwin 
uname -v = Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 

/usr/bin/uname -p = i386 
/bin/uname -X  = unknown 

/bin/arch    = unknown 
/usr/bin/arch -k  = unknown 
/usr/convex/getsysinfo = unknown 
/usr/bin/hostinfo  = Mach kernel version: 
    Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 
Kernel configured for up to 2 processors. 
2 processors are physically available. 
2 processors are logically available. 
Processor type: i486 (Intel 80486) 
Processors active: 0 1 
Primary memory available: 4.00 gigabytes 
Default processor set: 146 tasks, 635 threads, 2 processors 
Load average: 1.21, Mach factor: 0.99 
/bin/machine   = unknown 
/usr/bin/oslevel  = unknown 
/bin/universe   = unknown 

PATH: ~/work/emscripten 
PATH: ~/node_modules/.bin 
PATH: /opt/local/apache2/bin 
PATH: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin 
PATH: /opt/local/lib/postgresql90/bin 
PATH: /opt/local/bin 
PATH: /usr/bin 
PATH: ~/node_modules/.bin 
PATH: /opt/local/apache2/bin 
PATH: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin 
PATH: /opt/local/lib/postgresql90/bin 
PATH: /opt/local/bin 
PATH: /usr/bin 
PATH: /opt/local/bin 
PATH: /opt/local/sbin 
PATH: /usr/local/bin 
PATH: /usr/bin 
PATH: /bin 
PATH: /usr/sbin 
PATH: /sbin 
PATH: /usr/X11/bin 


## ----------- ## 
## Core tests. ## 
## ----------- ## 

configure:2764: checking for --enable-universalsdk 
configure:2805: result: no 
configure:2814: checking for --with-universal-archs 
configure:2831: result: 32-bit 
configure:2988: checking MACHDEP 
configure:3136: result: darwin 
configure:3142: checking EXTRAPLATDIR 
configure:3157: result: $(PLATMACDIRS) 
configure:3168: checking machine type as reported by uname -m 
configure:3171: result: x86_64 
configure:3184: checking for --without-gcc 
configure:3228: result: no 
configure:3289: checking for gcc 
configure:3316: result: /Users/calvin/work/emscripten/emcc 
configure:3545: checking for C compiler version 
configure:3554: /Users/calvin/work/emscripten/emcc --version >&5 
emcc (Emscripten GCC-like replacement) 2.0 
Copyright (C) 2011 the Emscripten authors. 
This is free and open source software under the MIT license. 
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

configure:3565: $? = 0 
configure:3554: /Users/calvin/work/emscripten/emcc -v >&5 
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn) 
Target: x86_64-apple-darwin11.2.0 
Thread model: posix 
clang: warning: argument unused during compilation: '-nostdinc' 
clang: warning: argument unused during compilation: '-nostdinc++' 
clang: warning: argument unused during compilation: '-Xclang -nobuiltininc' 
clang: warning: argument unused during compilation: '-Xclang -nostdinc++' 
clang: warning: argument unused during compilation: '-Xclang -nostdsysteminc' 
clang: warning: argument unused during compilation: '-Xclang -isystem/Users/calvin/work/emscripten/system/include' 
clang: warning: argument unused during compilation: '-Xclang -isystem/Users/calvin/work/emscripten/system/include/bsd' 
... rest of stderr output deleted ... 
configure:3565: $? = 0 
configure:3554: /Users/calvin/work/emscripten/emcc -V >&5 
clang: error: argument to '-V' is missing (expected 1 value) 
clang: error: no input files 
configure:3565: $? = 1 
configure:3554: /Users/calvin/work/emscripten/emcc -qversion >&5 
clang: error: no input files 
configure:3565: $? = 1 
configure:3585: checking whether the C compiler works 
configure:3607: /Users/calvin/work/emscripten/emcc conftest.c >&5 
error: unknown argument: '-nostdsysteminc' 
configure:3611: $? = 1 
configure:3649: result: no 
configure: failed program was: 
| /* confdefs.h */ 
| #define _GNU_SOURCE 1 
| #define _NETBSD_SOURCE 1 
| #define __BSD_VISIBLE 1 
| #define _BSD_TYPES 1 
| #define _DARWIN_C_SOURCE 1 
| /* end confdefs.h. */ 
| 
| int 
| main() 
| { 
| 
| ; 
| return 0; 
| } 
configure:3654: error: in `/Users/calvin/community/Python-2.7.2': 
configure:3656: error: C compiler cannot create executables 
See `config.log' for more details 

## ---------------- ## 
## Cache variables. ## 
## ---------------- ## 

ac_cv_env_CC_set=set 
ac_cv_env_CC_value=/Users/calvin/work/emscripten/emcc 
ac_cv_env_CFLAGS_set=set 
ac_cv_env_CFLAGS_value= 
ac_cv_env_CPPFLAGS_set= 
ac_cv_env_CPPFLAGS_value= 
ac_cv_env_CPP_set= 
ac_cv_env_CPP_value= 
ac_cv_env_LDFLAGS_set= 
ac_cv_env_LDFLAGS_value= 
ac_cv_env_LIBS_set= 
ac_cv_env_LIBS_value= 
ac_cv_env_build_alias_set= 
ac_cv_env_build_alias_value= 
ac_cv_env_host_alias_set= 
ac_cv_env_host_alias_value= 
ac_cv_env_target_alias_set= 
ac_cv_env_target_alias_value= 
ac_cv_prog_ac_ct_CC=/Users/calvin/work/emscripten/emcc 

## ----------------- ## 
## Output variables. ## 
## ----------------- ## 

AR='/Users/calvin/work/emscripten/emar' 
ARCH_RUN_32BIT='' 
ARFLAGS='' 
BASECFLAGS='' 
BLDLIBRARY='' 
BLDSHARED='' 
BUILDEXEEXT='' 
CC='/Users/calvin/work/emscripten/emcc' 
CCSHARED='' 
CFLAGS='' 
CFLAGSFORSHARED='' 
CONFIGURE_MACOSX_DEPLOYMENT_TARGET='' 
CONFIG_ARGS=' '\''CC=/Users/calvin/work/emscripten/emcc'\'' '\''CFLAGS='\''' 
CPP='' 
CPPFLAGS='' 
CXX='/Users/calvin/work/emscripten/em++' 
DEFS='' 
DLINCLDIR='' 
DLLLIBRARY='' 
DYNLOADFILE='' 
ECHO_C='\c' 
ECHO_N='' 
ECHO_T='' 
EGREP='' 
EXEEXT='' 
EXPORT_MACOSX_DEPLOYMENT_TARGET='#' 
EXTRAMACHDEPPATH='$(PLATMACPATH)' 
EXTRAPLATDIR='$(PLATMACDIRS)' 
FRAMEWORKALTINSTALLFIRST='' 
FRAMEWORKALTINSTALLLAST='' 
FRAMEWORKINSTALLAPPSPREFIX='' 
FRAMEWORKINSTALLFIRST='' 
FRAMEWORKINSTALLLAST='' 
FRAMEWORKUNIXTOOLSPREFIX='/usr/local' 
GNULD='' 
GREP='' 
HAS_HG='' 
HAVE_GETHOSTBYNAME='' 
HAVE_GETHOSTBYNAME_R='' 
HAVE_GETHOSTBYNAME_R_3_ARG='' 
HAVE_GETHOSTBYNAME_R_5_ARG='' 
HAVE_GETHOSTBYNAME_R_6_ARG='' 
HGBRANCH='' 
HGTAG='' 
HGVERSION='' 
INSTALL_DATA='' 
INSTALL_PROGRAM='' 
INSTALL_SCRIPT='' 
INSTSONAME='' 
LDCXXSHARED='' 
LDFLAGS='' 
LDLAST='' 
LDLIBRARY='' 
LDLIBRARYDIR='' 
LDSHARED='' 
LIBC='' 
LIBFFI_INCLUDEDIR='' 
LIBM='' 
LIBOBJS='' 
LIBRARY='' 
LIBS='' 
LIBTOOL_CRUFT='' 
LINKCC='' 
LINKFORSHARED='' 
LIPO_32BIT_FLAGS='' 
LN='' 
LTLIBOBJS='' 
MACHDEP='darwin' 
MACHDEP_OBJS='' 
MAINCC='' 
OBJEXT='' 
OPT='' 
OTHER_LIBTOOL_OPT='' 
PACKAGE_BUGREPORT='http://bugs.python.org/' 
PACKAGE_NAME='python' 
PACKAGE_STRING='python 2.7' 
PACKAGE_TARNAME='python' 
PACKAGE_URL='' 
PACKAGE_VERSION='2.7' 
PATH_SEPARATOR=':' 
PKG_CONFIG='' 
PYTHONFRAMEWORK='' 
PYTHONFRAMEWORKDIR='no-framework' 
PYTHONFRAMEWORKIDENTIFIER='org.python.python' 
PYTHONFRAMEWORKINSTALLDIR='' 
PYTHONFRAMEWORKPREFIX='' 
RANLIB='/Users/calvin/work/emscripten/emranlib' 
RUNSHARED='' 
SGI_ABI='' 
SHELL='/bin/sh' 
SHLIBS='' 
SIGNAL_OBJS='' 
SO='' 
SOVERSION='1.0' 
SRCDIRS='' 
SVNVERSION='' 
THREADHEADERS='' 
THREADOBJ='' 
TRUE='' 
UNICODE_OBJS='' 
UNIVERSALSDK='' 
UNIVERSAL_ARCH_FLAGS='' 
USE_SIGNAL_MODULE='' 
USE_THREAD_MODULE='' 
VERSION='2.7' 
ac_ct_CC='/Users/calvin/work/emscripten/emcc' 
bindir='${exec_prefix}/bin' 
build_alias='' 
datadir='${datarootdir}' 
datarootdir='${prefix}/share' 
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' 
dvidir='${docdir}' 
exec_prefix='NONE' 
host_alias='' 
htmldir='${docdir}' 
includedir='${prefix}/include' 
infodir='${datarootdir}/info' 
libdir='${exec_prefix}/lib' 
libexecdir='${exec_prefix}/libexec' 
localedir='${datarootdir}/locale' 
localstatedir='${prefix}/var' 
mandir='${datarootdir}/man' 
oldincludedir='/usr/include' 
pdfdir='${docdir}' 
prefix='NONE' 
program_transform_name='s,x,x,' 
psdir='${docdir}' 
sbindir='${exec_prefix}/sbin' 
sharedstatedir='${prefix}/com' 
sysconfdir='${prefix}/etc' 
target_alias='' 

## ----------- ## 
## confdefs.h. ## 
## ----------- ## 

/* confdefs.h */ 
#define _GNU_SOURCE 1 
#define _NETBSD_SOURCE 1 
#define __BSD_VISIBLE 1 
#define _BSD_TYPES 1 
#define _DARWIN_C_SOURCE 1 

configure: exit 77 
+0

它看起來像你在OS X上。Emscripten在Mac上無法正常工作。您可能不得不切換到Linux。 – jterrace 2012-02-05 04:04:19

+0

好吧,我會在我的arch linux實例上試試它,看看是否可行。謝謝。 – 2012-02-05 14:01:49

+0

@CalvinCheng - 它與Linux一起工作? – ragulka 2013-02-13 21:02:59

回答

5

見關於編譯項目的Emscripten wiki頁面,

http://kripken.github.io/emscripten-site/docs/compiling/Building-Projects.html

還有一個項目,編譯Python來Emscripten,empythoned,

https://github.com/replit/empythoned

我不知道它是最新的,但。

+0

歡迎來到SO,Alon!我添加了emscripten標籤,如果你想訂閱它 – jterrace 2012-01-29 22:26:53

+0

@Alon:謝謝你的兩個鏈接!我可以澄清在命令'emcc [-Ox] project.bc -o project.js'中有什麼'project.bc'?我知道這是「項目位代碼」,但是在嘗試將我的「python解釋器」轉換爲「python.cc.js」python js解釋器時,這意味着什麼? – 2012-01-30 00:27:57

+1

@CalvinCheng''.bc''是LLVM位碼。 LLVM可以有兩種形式:'.ll''和''.bc''。基本流程是''.c - > .bc/.ll - > .js'' – jterrace 2012-01-30 14:36:34