|
@@ -41,7 +41,8 @@ Class BuildProduct
|
|
|
|
|
|
Method Build()
|
|
Method Build()
|
|
|
|
|
|
- If opts.verbose=0 Print "Compiling..."
|
|
|
|
|
|
+' If opts.verbose=0
|
|
|
|
+ Print "Compiling..."
|
|
|
|
|
|
If Not CreateDir( module.cacheDir ) Throw New BuildEx( "Error creating dir '"+module.cacheDir+"'" )
|
|
If Not CreateDir( module.cacheDir ) Throw New BuildEx( "Error creating dir '"+module.cacheDir+"'" )
|
|
|
|
|
|
@@ -112,7 +113,7 @@ Class BuildProduct
|
|
|
|
|
|
Method Exec:Bool( cmd:String,eatstdout:Bool=False )
|
|
Method Exec:Bool( cmd:String,eatstdout:Bool=False )
|
|
|
|
|
|
- If opts.verbose>2 Print cmd
|
|
|
|
|
|
+ If opts.verbose=3 Print cmd
|
|
|
|
|
|
Local fstdout:=eatstdout ? AllocTmpFile( "stdout" ) Else ""
|
|
Local fstdout:=eatstdout ? AllocTmpFile( "stdout" ) Else ""
|
|
|
|
|
|
@@ -299,48 +300,40 @@ Class GccBuildProduct Extends BuildProduct
|
|
|
|
|
|
Select opts.toolchain
|
|
Select opts.toolchain
|
|
Case "msvc"
|
|
Case "msvc"
|
|
-
|
|
|
|
CC_CMD= "cl -c"
|
|
CC_CMD= "cl -c"
|
|
CXX_CMD="cl -c"
|
|
CXX_CMD="cl -c"
|
|
AS_CMD=opts.arch="x64" ? "ml64 -c" Else "ml -c"
|
|
AS_CMD=opts.arch="x64" ? "ml64 -c" Else "ml -c"
|
|
AR_CMD="lib"
|
|
AR_CMD="lib"
|
|
LD_CMD="link"
|
|
LD_CMD="link"
|
|
target="_MSVC"
|
|
target="_MSVC"
|
|
-
|
|
|
|
Case "gcc"
|
|
Case "gcc"
|
|
-
|
|
|
|
Select opts.target
|
|
Select opts.target
|
|
Case "emscripten"
|
|
Case "emscripten"
|
|
-
|
|
|
|
CC_CMD= "emcc -c"
|
|
CC_CMD= "emcc -c"
|
|
CXX_CMD="em++ -c"
|
|
CXX_CMD="em++ -c"
|
|
- AR_CMD="emar"
|
|
|
|
LD_CMD="em++"
|
|
LD_CMD="em++"
|
|
-
|
|
|
|
|
|
+ AR_CMD="em++ -o"
|
|
Case "raspbian"
|
|
Case "raspbian"
|
|
-
|
|
|
|
CC_CMD= "arm-linux-gnueabihf-gcc -c"
|
|
CC_CMD= "arm-linux-gnueabihf-gcc -c"
|
|
CXX_CMD="arm-linux-gnueabihf-g++ -c"
|
|
CXX_CMD="arm-linux-gnueabihf-g++ -c"
|
|
- AS_CMD= "arm-linux-gnueabihf-as"
|
|
|
|
- AR_CMD= "arm-linux-gnueabihf-ar"
|
|
|
|
LD_CMD= "arm-linux-gnueabihf-g++"
|
|
LD_CMD= "arm-linux-gnueabihf-g++"
|
|
-
|
|
|
|
|
|
+ AR_CMD= "arm-linux-gnueabihf-ar q"
|
|
|
|
+ AS_CMD= "arm-linux-gnueabihf-as"
|
|
|
|
+ Case "ios"
|
|
|
|
+ CC_CMD= "gcc -c"
|
|
|
|
+ CXX_CMD="g++ -c"
|
|
|
|
+ LD_CMD= "g++"
|
|
|
|
+ AR_CMD= "libtool"
|
|
|
|
+ AS_CMD= "as"
|
|
Default
|
|
Default
|
|
-
|
|
|
|
- Local suffix:=GetEnv( "MX2_GCC_SUFFIX" )
|
|
|
|
-
|
|
|
|
- CC_CMD= "gcc"+suffix+" -c "
|
|
|
|
- CXX_CMD="g++"+suffix+" -c "
|
|
|
|
|
|
+ CC_CMD= "gcc -c"
|
|
|
|
+ CXX_CMD="g++ -c"
|
|
|
|
+ LD_CMD= "g++"
|
|
|
|
+ AR_CMD= "ar q"
|
|
AS_CMD= "as"
|
|
AS_CMD= "as"
|
|
- AR_CMD= "ar"
|
|
|
|
- LD_CMD= "g++"+suffix+" "
|
|
|
|
-
|
|
|
|
End
|
|
End
|
|
-
|
|
|
|
Default
|
|
Default
|
|
-
|
|
|
|
- RuntimeError( "Toolchain error: '"+opts.toolchain+"'" )
|
|
|
|
-
|
|
|
|
|
|
+ RuntimeError( "Unrecognized error: '"+opts.toolchain+"'" )
|
|
End
|
|
End
|
|
|
|
|
|
CC_CMD+=" "+GetEnv( "MX2_CC_OPTS"+target )+" "+GetEnv( "MX2_CC_OPTS"+target+config )
|
|
CC_CMD+=" "+GetEnv( "MX2_CC_OPTS"+target )+" "+GetEnv( "MX2_CC_OPTS"+target+config )
|
|
@@ -348,7 +341,6 @@ Class GccBuildProduct Extends BuildProduct
|
|
AS_CMD+=" "+GetEnv( "MX2_AS_OPTS"+target )+" "+GetEnv( "MX2_AS_OPTS"+target+config )
|
|
AS_CMD+=" "+GetEnv( "MX2_AS_OPTS"+target )+" "+GetEnv( "MX2_AS_OPTS"+target+config )
|
|
AR_CMD+=" "+GetEnv( "MX2_AR_OPTS"+target )+" "+GetEnv( "MX2_AR_OPTS"+target+config )
|
|
AR_CMD+=" "+GetEnv( "MX2_AR_OPTS"+target )+" "+GetEnv( "MX2_AR_OPTS"+target+config )
|
|
LD_CMD+=" "+GetEnv( "MX2_LD_OPTS"+target )+" "+GetEnv( "MX2_LD_OPTS"+target+config )
|
|
LD_CMD+=" "+GetEnv( "MX2_LD_OPTS"+target )+" "+GetEnv( "MX2_LD_OPTS"+target+config )
|
|
-
|
|
|
|
End
|
|
End
|
|
|
|
|
|
Method CompileSource:String( src:String )
|
|
Method CompileSource:String( src:String )
|
|
@@ -432,7 +424,7 @@ Class GccBuildProduct Extends BuildProduct
|
|
DeleteFile( deps )
|
|
DeleteFile( deps )
|
|
Endif
|
|
Endif
|
|
|
|
|
|
- If opts.verbose>0 Print StripDir( src )
|
|
|
|
|
|
+ If opts.verbose=1 Print StripDir( src )
|
|
|
|
|
|
If opts.toolchain<>"msvc"
|
|
If opts.toolchain<>"msvc"
|
|
|
|
|
|
@@ -458,7 +450,7 @@ Class GccBuildProduct Extends BuildProduct
|
|
|
|
|
|
cmd+=" -MMD -MF~q"+deps+"~q"
|
|
cmd+=" -MMD -MF~q"+deps+"~q"
|
|
cmd+=" -o ~q"+obj+"~q ~q"+src+"~q"
|
|
cmd+=" -o ~q"+obj+"~q ~q"+src+"~q"
|
|
- If opts.verbose>2 Print cmd
|
|
|
|
|
|
+
|
|
Exec( cmd )
|
|
Exec( cmd )
|
|
|
|
|
|
Local buf:=New StringStack
|
|
Local buf:=New StringStack
|
|
@@ -483,7 +475,6 @@ Class GccBuildProduct Extends BuildProduct
|
|
Local fstdout:=AllocTmpFile( "stdout" )
|
|
Local fstdout:=AllocTmpFile( "stdout" )
|
|
cmd+=" -showIncludes -Fo~q"+obj+"~q ~q"+src+"~q >"+fstdout
|
|
cmd+=" -showIncludes -Fo~q"+obj+"~q ~q"+src+"~q >"+fstdout
|
|
|
|
|
|
- If opts.verbose>2 Print cmd
|
|
|
|
Local fstderr:=AllocTmpFile( "stderr" )
|
|
Local fstderr:=AllocTmpFile( "stderr" )
|
|
If system( cmd+" 2>"+fstderr )
|
|
If system( cmd+" 2>"+fstderr )
|
|
Local buf:=New StringStack
|
|
Local buf:=New StringStack
|
|
@@ -537,20 +528,22 @@ Class GccBuildProduct Extends BuildProduct
|
|
objs.AddAll( OBJ_FILES )
|
|
objs.AddAll( OBJ_FILES )
|
|
|
|
|
|
If opts.productType="module"
|
|
If opts.productType="module"
|
|
-
|
|
|
|
BuildModule( objs )
|
|
BuildModule( objs )
|
|
-
|
|
|
|
Else
|
|
Else
|
|
-
|
|
|
|
BuildApp( objs )
|
|
BuildApp( objs )
|
|
End
|
|
End
|
|
End
|
|
End
|
|
|
|
|
|
Method BuildModule( objs:StringStack )
|
|
Method BuildModule( objs:StringStack )
|
|
-
|
|
|
|
|
|
+
|
|
Local output:=module.afile
|
|
Local output:=module.afile
|
|
- If opts.toolchain="msvc" output=StripExt(output)+".lib"
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ If opts.toolchain="msvc"
|
|
|
|
+ output=StripExt( output )+".lib"
|
|
|
|
+ Else if opts.target="emscripten"
|
|
|
|
+ output=StripExt( output )+".bc"
|
|
|
|
+ Endif
|
|
|
|
+
|
|
Local maxObjTime:Long
|
|
Local maxObjTime:Long
|
|
For Local obj:=Eachin objs
|
|
For Local obj:=Eachin objs
|
|
maxObjTime=Max( maxObjTime,GetFileTime( obj ) )
|
|
maxObjTime=Max( maxObjTime,GetFileTime( obj ) )
|
|
@@ -566,33 +559,21 @@ Class GccBuildProduct Extends BuildProduct
|
|
args+=" ~q"+objs.Get( i )+"~q"
|
|
args+=" ~q"+objs.Get( i )+"~q"
|
|
Next
|
|
Next
|
|
|
|
|
|
- If opts.target="ios"
|
|
|
|
|
|
+ cmd=AR_CMD
|
|
|
|
+#If __TARGET__="windows"
|
|
|
|
+ Local tmp:=AllocTmpFile( "libFiles" )
|
|
|
|
+ SaveString( args,tmp )
|
|
|
|
|
|
- cmd="libtool -o ~q"+output+"~q"+args
|
|
|
|
-
|
|
|
|
- Else If opts.toolchain="msvc"
|
|
|
|
-
|
|
|
|
- Local tmp:=AllocTmpFile( "libFiles" )
|
|
|
|
- SaveString( args,tmp )
|
|
|
|
-
|
|
|
|
- cmd="lib -out:~q"+output+"~q @~q"+tmp+"~q"
|
|
|
|
-
|
|
|
|
|
|
+ If opts.toolchain="msvc"
|
|
|
|
+ cmd+=" -out:~q"+output+"~q @~q"+tmp+"~q"
|
|
Else
|
|
Else
|
|
-
|
|
|
|
-#If __TARGET__="windows"
|
|
|
|
-
|
|
|
|
- Local tmp:=AllocTmpFile( "libFiles" )
|
|
|
|
- SaveString( args,tmp )
|
|
|
|
-
|
|
|
|
- cmd=AR_CMD+" q ~q"+output+"~q @~q"+tmp+"~q"
|
|
|
|
-
|
|
|
|
|
|
+ cmd+=" ~q"+output+"~q @~q"+tmp+"~q"
|
|
|
|
+ Endif
|
|
#Else
|
|
#Else
|
|
- cmd=AR_CMD+" q ~q"+output+"~q"+args
|
|
|
|
|
|
+ cmd+=" ~q"+output+"~q"+args
|
|
#Endif
|
|
#Endif
|
|
- Endif
|
|
|
|
|
|
|
|
Exec( cmd,opts.toolchain="msvc" )
|
|
Exec( cmd,opts.toolchain="msvc" )
|
|
-
|
|
|
|
End
|
|
End
|
|
|
|
|
|
Method BuildApp( objs:StringStack ) Virtual
|
|
Method BuildApp( objs:StringStack ) Virtual
|
|
@@ -695,7 +676,11 @@ Class GccBuildProduct Extends BuildProduct
|
|
|
|
|
|
For Local imp:=Eachin imports
|
|
For Local imp:=Eachin imports
|
|
Local afile:=imp.afile
|
|
Local afile:=imp.afile
|
|
- If opts.toolchain="msvc" afile=StripExt(afile)+".lib"
|
|
|
|
|
|
+ If opts.target="emscripten"
|
|
|
|
+ afile=StripExt(afile)+".bc"
|
|
|
|
+ Else If opts.toolchain="msvc"
|
|
|
|
+ afile=StripExt(afile)+".lib"
|
|
|
|
+ Endif
|
|
lnkFiles+=" ~q"+afile+"~q"
|
|
lnkFiles+=" ~q"+afile+"~q"
|
|
Next
|
|
Next
|
|
|
|
|