Version 3 (modified by 8 years ago) ( diff ) | ,
---|
Work in progress
Developing and deploying an Application
...using Smalltalk/X jv-branch
This tutorial shows am (almost) complete development cycle for a hypothetical application helloworld_0. not the coolest name, I know. You should choose better for your app!
Step 1: Preparing Development Environment
First you need to make sure you're able to compile Smalltalk/X jv-branch as such. To do so, follow instructions described in section Building Smalltalk/X jv-branch. Especially make sure you have installed a C compiler toolchain and version control tools as they'll be needed.
Through this tutorial, let's assume all the files should go into directory demo0
. So, start with checking
out essential build scripts that will help to fetch core source and set up a working Smalltalk/X jv-branch build environment:
hg clone hg clone https://bitbucket.org/janvrany/stx-goodies-builder-rake demo0 cd demo0 rake
Step 2: Creating a Repository for Application Code
Let's assume you're starting on a green field. You need to store your sources in a version control. Smalltalk/X jv-branch comes with decent support for Mercurial so let's use it. You may also use CVS but, believe me, you don't want to use it especially if you may use Mercurial.
First, you need to decide to which (Smalltalk/X) package would code go. Let's say it should go to package named jv:demos/helloworld_0. So, go to build
subdir and create a new repository for it:
mkdir build\jv\demos hg init build\jv\demos\helloworld_0
That's it.
Step 3: Create Initial Application Code
Now it's time to write some code. Basically you need to create at least three classes:
jv_demos_helloworld_0
- so called project definition class. This class contains a metadata about the package. Think of it as setup.py in Python or .gemspec in Ruby.HelloWorld0
- the main application class. This is where the real logic is.HelloWorld0Start
- the application entry point. When the application is compiled to a standalone executable, once the Smalltalk/X VM initialize itself, it transfer control toHelloWorld0Start>>main:
passing command line arguments. Think of it as ofint main(int artc, char **argv)
in C. In this method you may process command line arguments and eventually fire the main application -HelloWorld0>>open
.
Let's so it. Launch Smalltalk/X IDE:
cd build\stx\projects\smalltalk smalltalk -I --quick
Open a system browser, switch to package view (from menu pick View ▷ Package). Then create a new package using menu pick Package ▷ New...:
This will create (almost) all the necessary code for you:
- In the first dialog, choose GUI-Application as application type and fill in a package name - jv:demos/helloworld_0 and click Create. This would create an empty "application" package.
- Then you'd be asked for an application class name. Fill in
HelloWorld0
. Once you click OK the wizard will create the class and generate some initial code. You may change the code later. - Then you'd be asked for a statup class name. Likewise, this will create an initial startup class and generate a default
main:
method that will open an application specified in previous step.
Although most fo the code has been generated, one little tweak may be needed. When user closes main application window either by clicking to X button in titlebar or picking an exit menu item, we'd like the whole application to terminate. This is not done automatically but it's easy to fix. All we need to is in method
HelloWorld0>>closeDownViews
call Smalltalk exitIfStandalone: 0
:
Do not call plain old Smalltalk exit:0
. The problem with this is that if called from IDE (for example
when debugging or testing the application) it would terminate the IDE which is likely something you don't want.
Step 4: Commiting Code
To commit the code to Mercurial repository, simply select the package in browser and pick Package ▷ Repository ▷ CheckIn... menu. Fill in a commit message and click Commit:
Step 5: Compiling Standalone Application
By standalone application we mean an executable (.exe on Windows) and bunch of libraries (.so or .dll) which can be deployed at user machine.
First we need to update a working to the latest code:
cd build\jv\demos\helloworld_0 hg up
Use hg sum
that correct revision is checked out. To compile the application, just do
bin\setenv.bat cd build\jv\demos\helloworld_0 mingwmake
On Linux, just do
cd build\jv\demos\helloworld_0 make
If compilation succeeds, you should find helloworld_0.exe
there. Just run it and your new application should comeup:
Time for a beer!
Topics not (yet) covered
- Creating installer
- Configuring Jenkins job
Attachments (14)
- helloworld_0-001.png (33.6 KB ) - added by 8 years ago.
- helloworld_0-002.PNG (58.0 KB ) - added by 8 years ago.
- helloworld_0-003.PNG (44.6 KB ) - added by 8 years ago.
- helloworld_0-004.PNG (5.1 KB ) - added by 8 years ago.
- default_source_code_management.png (88.1 KB ) - added by 8 years ago.
- module_settings.png (135.6 KB ) - added by 8 years ago.
- settings_mercurial.png (106.3 KB ) - added by 8 years ago.
- manual_update.png (7.5 KB ) - added by 8 years ago.
- loading_from_merucrial_to_stx.png (16.6 KB ) - added by 8 years ago.
- message_in_the_stx_launcher.png (41.8 KB ) - added by 8 years ago.
- correctly_loaded_package.png (95.1 KB ) - added by 8 years ago.
- reopening_in_gui_painter.png (172.1 KB ) - added by 8 years ago.
- alternative_way_to_reopen_gui_in_gui_painter.png (109.3 KB ) - added by 8 years ago.
- editing_menus.png (149.5 KB ) - added by 8 years ago.
Download all attachments as: .zip