Home | History | Annotate | Download | only in desktop
      1 /*******************************************************************************
      2  * Copyright 2011 See AUTHORS file.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *   http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  ******************************************************************************/
     16 
     17 package com.badlogic.gdx.controllers.desktop;
     18 
     19 import com.badlogic.gdx.jnigen.AntScriptGenerator;
     20 import com.badlogic.gdx.jnigen.BuildConfig;
     21 import com.badlogic.gdx.jnigen.BuildExecutor;
     22 import com.badlogic.gdx.jnigen.BuildTarget;
     23 import com.badlogic.gdx.jnigen.NativeCodeGenerator;
     24 import com.badlogic.gdx.jnigen.BuildTarget.TargetOs;
     25 
     26 public class DesktopControllersBuild {
     27 	public static void main (String[] args) throws Exception {
     28 		new NativeCodeGenerator().generate("src/", "bin/", "jni/");
     29 		BuildConfig buildConfig = new BuildConfig("gdx-controllers-desktop");
     30 
     31 		String[] windowsSrc = {"*.cpp", "ois-v1-4svn/src/*.cpp", "ois-v1-4svn/src/win32/*.cpp"};
     32 
     33 		String[] linuxSrc = {"*.cpp", "ois-v1-4svn/src/*.cpp", "ois-v1-4svn/src/linux/*.cpp"};
     34 
     35 		String[] mac64Src = {"*.cpp", "ois-v1-4svn/src/*.cpp", "ois-v1-4svn/src/mac/*.mm", "ois-v1-4svn/src/mac/MacHIDManager.cpp",
     36 			"ois-v1-4svn/src/mac/MacJoyStick.cpp",};
     37 
     38 		String[] includes = new String[] {"ois-v1-4svn/includes", "dinput/"};
     39 
     40 		BuildTarget win32home = BuildTarget.newDefaultTarget(TargetOs.Windows, false);
     41 		win32home.buildFileName = "build-windows32home.xml";
     42 		win32home.excludeFromMasterBuildFile = true;
     43 		win32home.is64Bit = false;
     44 		win32home.compilerPrefix = "";
     45 		win32home.cppIncludes = windowsSrc;
     46 		win32home.headerDirs = includes;
     47 		win32home.cIncludes = new String[0];
     48 		win32home.libraries = "-ldinput8 -ldxguid";
     49 
     50 		BuildTarget win32 = BuildTarget.newDefaultTarget(TargetOs.Windows, false);
     51 		win32.cppIncludes = windowsSrc;
     52 		win32.headerDirs = includes;
     53 		win32.libraries = "-ldinput8 -ldxguid";
     54 
     55 		BuildTarget win64 = BuildTarget.newDefaultTarget(TargetOs.Windows, true);
     56 		win64.cppIncludes = windowsSrc;
     57 		win64.headerDirs = includes;
     58 		win64.libraries = "-ldinput8 -ldxguid";
     59 
     60 		BuildTarget lin32 = BuildTarget.newDefaultTarget(TargetOs.Linux, false);
     61 		lin32.cppIncludes = linuxSrc;
     62 		lin32.headerDirs = includes;
     63 		lin32.libraries = "-lX11";
     64 
     65 		BuildTarget lin64 = BuildTarget.newDefaultTarget(TargetOs.Linux, true);
     66 		lin64.cppIncludes = linuxSrc;
     67 		lin64.headerDirs = includes;
     68 		lin64.libraries = "-lX11";
     69 
     70 		BuildTarget mac = BuildTarget.newDefaultTarget(TargetOs.MacOsX, false);
     71 		mac.cppIncludes = mac64Src;
     72 		mac.headerDirs = includes;
     73 		mac.cppFlags += " -x objective-c++";
     74 		mac.libraries = "-framework CoreServices -framework Carbon -framework IOKit -framework Cocoa";
     75 
     76 		BuildTarget mac64 = BuildTarget.newDefaultTarget(TargetOs.MacOsX, true);
     77 		mac64.cppIncludes = mac64Src;
     78 		mac64.headerDirs = includes;
     79 		mac64.cppFlags += " -x objective-c++";
     80 		mac64.libraries = "-framework CoreServices -framework Carbon -framework IOKit -framework Cocoa";
     81 
     82 		new AntScriptGenerator().generate(buildConfig, win32home, win32, win64, lin32, lin64, mac, mac64);
     83 //		if (!BuildExecutor.executeAnt("jni/build-macosx32.xml", "-Dhas-compiler=true -v postcompile")) {
     84 //			throw new Exception("build failed");
     85 //		}
     86 //		BuildExecutor.executeAnt("jni/build.xml", "pack-natives");
     87 	}
     88 }
     89