| C H A P T E R 2 |
|
Quick Start: Building on Windows for Windows |
This chapter describes building on Windows for Windows. It covers building and running your very own Java Wireless Client software stack. The purpose of this chapter is to whisk you through the build process for the entire Java Wireless Client software stack. Later chapters describe all the options for each part of the build.
This chapter presents example scripts that help you set up your environment and run the different parts of the build. The scripts are available in docs/build-scripts/win32-x86. Once you have everything set up, run the scripts to perform the build. Work along as you read through the chapter to understand how it all fits together.
Consult the Release Notes for the very latest information on tool versions.
The core of the Java Wireless Client software build on Windows is Microsoft's compiler, cl.exe. Use Microsoft Visual C++ 6.0 Professional Edition. Although other development packages from Microsoft include the compiler, they are incompatible in various ways and cannot be used without modifying the build system or source code.
To use the compiler, you need to add it to your PATH environment variable and update the INCLUDE and LIB variables to appropriate values. Microsoft provides a batch file to set PATH, INCLUDE, and LIB to appropriate values. This batch file is vcvars32.bat.
GNU Make and other UNIX system-style tools are available for Windows in a package called Cyg4Me. Get it here:
ftp://ftp.sunfreeware.com/pub/freeware/contributions/cygwin/cyg4me1_1_full.zip
Cyg4Me is a specialized version of a more widely known package, Cygwin. Use Cyg4Me rather than Cygwin.
You will need to set your path so that all of the tools are available. Here is an example batch file.
This batch file is docs/build-scripts/win32-x86/setpath.bat. Edit it so the values for the following variables are correct for your build system:
After you set the values appropriately, run the batch file like this:
D:\jwc\docs\build-scripts\win32-x86>setpath Setting environment for using Microsoft Visual C++ x86 tools. D:\jwc\docs\build-scripts\win32-x86> |
Run the scripts in the rest of this chapter from the same command line.
The Windows build is sensitive with respect to paths. Be careful when you define them, as certain forms of paths succeed in some parts of the build and fail in others. Follow the supplied scripts as closely as possible until you are comfortable with the build system.
In addition, the length of the paths you are using might also cause trouble in the build. Place the Java Wireless Client software source code in a location with a short path. The examples in this book are based on having the entire source code tree in d:\jwc.
These examples show how to find out if you have set your PATH correctly and have the right tools available:
The remainder of the build scripts presented in this chapter operate using Cyg4Me's shell, not the Windows command line. However, you will execute the scripts from the Windows command line, using sh to invoke the Cyg4Me shell. You'll see examples as you read the rest of the chapter.
Each of the build scripts in the rest of this chapter operate by setting up, doing some work, and cleaning up.
The setting up script is setup.sh and the cleaning up script is teardown.sh.
export Acme=d:/jwc export Scripts=`pwd` export Output=$Acme/output export Log=$Acme/log.txt rm -f $Log |
This script is available as docs/build-scripts/win32-x86/setup.sh.
The Acme variable is the top level of the Java Wireless Client software. Adjust the value to point to the top level of your own installation. Don't run this script yet. It is used by the build scripts in the rest of this chapter.
You do not need to modify this script.
Three variables must be defined to build the JavaCall API.
Two of these variables point to the JavaCall API source code, which is split into a base (open source) component and a product (commercial) component. Use JAVACALL_DIR to point to the base JavaCall API directory, usually javacall. Next, point JAVACALL_PROJECT_DIR to the javacall-com directory.
The third variable, JAVACALL_OUTPUT_DIR, tells the build system where to put the output of the JavaCall API build.
You need to run the build from javacall-com/configuration/irbis/win32_x86.
Here is a simple script to build the JavaCall API, build-javacall.sh:
You should be able to run this script unmodified. This script uses the setup.sh and teardown.sh scripts from the previous section.
Go ahead and give it a whirl. Remember, you are still using the Windows command line, but you're going to invoke the script using Cyg4Me's sh shell. Messages display as the build progresses, with a success message at the very end.
The output goes in $Acme/output/javacall. Take a look:
D:\jwc\docs\build-scripts\win32-x86>ls d:\jwc\output\javacall ext_lib inc lib obj D:\jwc\docs\build-scripts\win32-x86> |
The next step is to build PCSL. You have to tell PCSL the target platform and where to put output files. Because you are building PCSL on top of the JavaCall API, which is built on top of Windows (i386) using Visual C++ or Visual Studio (vc), the PCSL_PLATFORM variable should be javacall_i386_vc.
JAVACALL_OUTPUT_DIR needs to be set so that the PCSL build can find the JavaCall API files that it needs. Usually, JAVACALL_OUTPUT_DIR will still be set from your JavaCall API build.
Tell PCSL where to put its output files with the PCSL_OUTPUT_DIR variable.
Here is a script, build-pcsl.sh, that performs the build:
This script uses the same setup.sh and teardown.sh scripts as before. Again, you can use build-pcsl.sh without modifying it.
Run the script the same way you ran the JavaCall API build script:
At the end is a message about the success of the PCSL build.
Browse through the output files in output/pcsl if you want to see the results of the build.
CLDC is built on top of PCSL and the JavaCall API. Tell CLDC to use PCSL by setting ENABLE_PCSL to true, and specify where to find PCSL with PCSL_OUTPUT_DIR.
Tell the CLDC build system where to find the JavaCall API with JAVACALL_OUTPUT_DIR.
In addition, the CLDC build system expects you to define several environment variables.
The following script, build-cldc.sh, runs the CLDC build.
Run it with sh build-cldc.sh. After a few minutes and a success message at the end of the build, you can browse the output in output/cldc.
The last step in creating a Java Wireless Client software stack is building MIDP and optional APIs. This chapter describes how to build MIDP only. Later chapters describe how to include optional APIs in this part of the build and describe the many variables you can use to change how Java Wireless Client software is built.
For now, build MIDP using the CLDC, PCSL, and the JavaCall API output you already generated.
You need JDK_DIR defined, just as it was for the CLDC build. In addition, you must tell the MIDP build where to find the JavaCall API, PCSL, and CLDC:
The first thing that happens with the MIDP build is that tools are created for use later in the build. Use TOOLS_DIR to point to the tools directory.
Finally, set MIDP_OUTPUT_DIR to the location that contains the output of the build when it is complete.
Run the build from the midp/build/javacall directory. Here is a script, build-sjwc.sh, that sets the necessary variables and runs the MIDP build:
Run this script with sh build-sjwc.sh. Wait until you see the message sjwc_status=OK at the end of the build. Congratulations! You've just built a complete MIDP stack.
To run the Java Wireless Client software stack in a simulated device, change directories to output\midp\bin\i386. Now run usertest.
A simulated device is displayed.
You can install and test MIDlets on this simulated device. See the Tools Guide for complete details.
Copyright © 2007, Sun Microsystems, Inc. All rights reserved. SUN PROPRIETARY/CONFIDENTIAL.