Browse Source

Merge branch 'master' of github.com:amber-smalltalk/amber

Nicolas Petton 10 years ago
parent
commit
2460c3d022
5 changed files with 128 additions and 101 deletions
  1. 24 1
      CHANGELOG
  2. 83 80
      bin/amberc
  3. 5 8
      bin/amberc.js
  4. 2 2
      bin/release.sh
  5. 14 10
      bin/setversion.sh

+ 24 - 1
CHANGELOG

@@ -69,11 +69,34 @@ To install Amber from Bower, run
 
 * Migration from Amber 0.11.0
 
+First, you must change loading part. The proprietary loader is gone,
+you have to use requirejs for loading. New loader code is thouroughly
+explained in [4].
+
+After changing the loader part, you need to recompile all your `.st` files
+into new AMD `.js` files. During loader changes, you had to choose a namespace,
+this will be needed now.
+
+Go to your directory with `.st` files and issue this from the shell:
+
+```sh
+<path-to-amber>/bin/amberc -l SUnit,Canvas -n <the-namespace-you-have-chosen> -D <path-for-compiled-js-files> *.st
+```
+
+In windows, use `\` as path separator, the rest is identical.
+
+The `-l SUnit,Canvas` is just a general guess, if your code depends on more (or less) non-kernel packages from amber, list them here accordingly.
+
+This migrate scenario only covers simple deployments with your project's code and amber.
+If your project is more compilicated, using libraries and packages from multiple sources,
+it is hard to give general advices to migrate - you must do it library by library,
+giving each location its own namespace, and `-L` option of `amberc`
+comes handy when integrating; ask on the mailing list if problems arise.
 
 [1] http://requirejs.org/
 [2] http://bower.io/
 [3] https://github.com/amber-smalltalk/brikz
-
+[4] https://github.com/amber-smalltalk/amber/wiki/How-to-load-amber
 
 
 09th July 2013 - Release 0.11.0

+ 83 - 80
bin/amberc

@@ -102,84 +102,87 @@ function handle_options(optionsArray) {
 
 // print available flags
 function print_usage() {
-	console.log('Usage: amberc [-l lib1,lib2...] [-g jsGlobal1,jsGlobla2] [-m main_class] [-M main_file]');
-	console.log('          [-n namespace] [-D output_dir] [-v] [-s suffix] [-S suffix] [file1 [file2 ...]] [Program]');
-	console.log('');
-	console.log('   amberc compiles Amber files - either separately or into a complete runnable');
-	console.log('   program. If no .st files are listed only a linking stage is performed.');
-	console.log('   Files listed will be handled using the following rules:');
-	console.log('');
-	console.log('   *.js');
-	console.log('     Files are linked (concatenated) in listed order.');
-	console.log('     If not found we look in $AMBER/js/');
-	console.log('');
-	console.log('   *.st');
-	console.log('     Files are compiled into .js files before concatenation.');
-	console.log('     If not found we look in $AMBER/st/.');
-	console.log('');
-	console.log('     NOTE: Each .st file is currently considered to be a fileout of a single class');
-	console.log('     category of the same name as the file!');
-	console.log('');
-	console.log('   If no <Program> is specified each given .st file will be compiled into');
-	console.log('   a matching .js file. Otherwise a <Program>.js file is linked together based on');
-	console.log('   the given options:');
-	console.log('');
-	console.log('  -l library1,library2');
-	console.log('     Add listed JavaScript libraries in listed order.');
-	console.log('     Libraries are not separated by spaces or end with .js.');
-	console.log('');
-	console.log('  -L directory1,directory2');
-	console.log('     Add listed directories to the library search path.');
-	console.log('     The order of processing is:');
-	console.log('     1. current directory');
-	console.log('     2. directories specified by -L');
-	console.log('     3. $AMBER');
-	console.log('');
-	console.log('  -g jsGlobal1,jsGlobal2');
-	console.log('     Comma separated list of JS global variable names.');
-	console.log('     The names are added to a list containing "window", "document" and others.');
-	console.log('');
-	console.log('  -m main_class');
-	console.log('     Add a call to the class method main_class>>main at the end of <Program>.');
-	console.log('');
-	console.log('  -M main_file');
-	console.log('     Add <main_file> at the end of <Program.js> acting as #main.');
-	console.log('');
-	console.log('  -n amd_namespace');
-	console.log('     Export packages with <amd_namespace> as the require.js namespace.');
-	console.log('     Default value is "amber_core".');
-	console.log('');
-	console.log('  -v');
-	console.log('     Produce a more verbose output.');
-	console.log('');
-	console.log('  -D');
-	console.log('     Specifies the output directory for all generated .js files.');
-	console.log('     The hierarchy of the input files is not maintaned.');
-	console.log('     If this option is omitted all generated .js files are placed next to their input files');
-	console.log('');
-	console.log('  -s suffix');
-	console.log('     Add <suffix> to compiled .js files. File.st is then compiled into');
-	console.log('     File.<suffix>.js.');
-	console.log('');
-	console.log('  -S suffix');
-	console.log('     Use <suffix> for all libraries accessed using -l. This makes it possible');
-	console.log('     to have multiple flavors of Amber and libraries in the same place.');
-	console.log('');
-	console.log('');
-	console.log('     Example invocations:');
-	console.log('');
-	console.log('     Just compile Kernel-Objects.st to Kernel-Objects.js:');
-	console.log('');
-	console.log('        amberc Kernel-Objects.st');
-	console.log('');
-	console.log('     Compile Hello.st to Hello.js and create complete program called Program.js.');
-	console.log('     Additionally add a call to the class method Hello>>main:');
-	console.log('');
-	console.log('        amberc -m Hello Hello.st Program');
-	console.log('');
-	console.log('     Compile Cat1.st and Cat2.st files into corresponding .js files.');
-	console.log('     Link them with myboot.js and myKernel.js');
-	console.log('     and merge everything into a complete program named Program.js:');
-	console.log('');
-	console.log('        amberc -M main.js myboot.js myKernel.js Cat1.st Cat2.st Program');
+	var usage = [
+		'Usage: amberc [-l lib1,lib2...] [-g jsGlobal1,jsGlobla2] [-m main_class] [-M main_file]',
+		'          [-n namespace] [-D output_dir] [-v] [-s suffix] [-S suffix] [file1 [file2 ...]] [Program]',
+		'',
+		'   amberc compiles Amber files - either separately or into a complete runnable',
+		'   program. If no .st files are listed only a linking stage is performed.',
+		'   Files listed will be handled using the following rules:',
+		'',
+		'   *.js',
+		'     Files are linked (concatenated) in listed order.',
+		'     If not found we look in $AMBER/js/',
+		'',
+		'   *.st',
+		'     Files are compiled into .js files before concatenation.',
+		'     If not found we look in $AMBER/st/.',
+		'',
+		'     NOTE: Each .st file is currently considered to be a fileout of a single class',
+		'     category of the same name as the file!',
+		'',
+		'   If no <Program> is specified each given .st file will be compiled into',
+		'   a matching .js file. Otherwise a <Program>.js file is linked together based on',
+		'   the given options:',
+		'',
+		'  -l library1,library2',
+		'     Add listed JavaScript libraries in listed order.',
+		'     Libraries are not separated by spaces or end with .js.',
+		'',
+		'  -L directory1,directory2',
+		'     Add listed directories to the library search path.',
+		'     The order of processing is:',
+		'     1. current directory',
+		'     2. directories specified by -L',
+		'     3. $AMBER',
+		'',
+		'  -g jsGlobal1,jsGlobal2',
+		'     Comma separated list of JS global variable names.',
+		'     The names are added to a list containing "window", "document" and others.',
+		'',
+		'  -m main_class',
+		'     Add a call to the class method main_class>>main at the end of <Program>.',
+		'',
+		'  -M main_file',
+		'     Add <main_file> at the end of <Program.js> acting as #main.',
+		'',
+		'  -n amd_namespace',
+		'     Export packages with <amd_namespace> as the require.js namespace.',
+		'     Default value is "amber_core".',
+		'',
+		'  -v',
+		'     Produce a more verbose output.',
+		'',
+		'  -D',
+		'     Specifies the output directory for all generated .js files.',
+		'     The hierarchy of the input files is not maintaned.',
+		'     If this option is omitted all generated .js files are placed next to their input files',
+		'',
+		'  -s suffix',
+		'     Add <suffix> to compiled .js files. File.st is then compiled into',
+		'     File.<suffix>.js.',
+		'',
+		'  -S suffix',
+		'     Use <suffix> for all libraries accessed using -l. This makes it possible',
+		'     to have multiple flavors of Amber and libraries in the same place.',
+		'',
+		'',
+		'     Example invocations:',
+		'',
+		'     Just compile Kernel-Objects.st to Kernel-Objects.js:',
+		'',
+		'        amberc Kernel-Objects.st',
+		'',
+		'     Compile Hello.st to Hello.js and create complete program called Program.js.',
+		'     Additionally add a call to the class method Hello>>main:',
+		'',
+		'        amberc -m Hello Hello.st Program',
+		'',
+		'     Compile Cat1.st and Cat2.st files into corresponding .js files.',
+		'     Link them with myboot.js and myKernel.js',
+		'     and merge everything into a complete program named Program.js:',
+		'',
+		'        amberc -M main.js myboot.js myKernel.js Cat1.st Cat2.st Program',
+	];
+	usage.forEach(function (line) { console.log(line); });
 };

+ 5 - 8
bin/amberc.js

@@ -238,17 +238,14 @@ AmberC.prototype.resolve_js = function(filename, callback) {
 		} else {
 			var amberJsFile = '';
 			// check for specified .js file in any of the directories from jsLibraryDirs
-			var notFound = defaults.jsLibraryDirs.every(function(directory) {
+			var found = defaults.jsLibraryDirs.some(function(directory) {
 				amberJsFile = path.join(directory, jsFile);
-				if (fs.existsSync(amberJsFile)) {
-					return false;
-				}
-				return true;
+				return fs.existsSync(amberJsFile);
 			});
-			if (notFound) {
-				throw(new Error('JavaScript file not found: ' + jsFile));
-			} else {
+			if (found) {
 				callback(amberJsFile);
+			} else {
+				throw(new Error('JavaScript file not found: ' + jsFile));
 			}
 		}
 	});

+ 2 - 2
bin/release.sh

@@ -1,6 +1,6 @@
 #!/bin/sh
 cd `dirname "$0"`/..
-echo git reset --hard
+echo rm -rf *
 echo git checkout master
 echo -n "Which version are you going to publish [0 to skip]? "
 VER=`head -n 1`
@@ -17,7 +17,7 @@ if [ "$VER" = "0" ]; then :; else
 fi
 echo -n "Which version are you going to work on? "
 VERF=`head -n 1`
-VER="${VER}-pre"
+VER="${VERF}-pre"
 echo "Setting version $VER"
 bin/setversion.sh "$VER"
 cp package.json package.json.bak

+ 14 - 10
bin/setversion.sh

@@ -1,17 +1,21 @@
 #!/bin/sh
-cd `dirname "$0"`
-cd ../st
-rm -f *.js
+
+VERSION=$1
+cd `dirname "$0"`/../
+AMBER_BASE=`pwd`
+
+cd $AMBER_BASE/st
+# replace version number
 cp Kernel-Infrastructure.st Kernel-Infrastructure.st.bak
-sed -e "/^version\$/,/^\! \!\$/ s/\^ '[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\(-pre\)\{0,1\}'\$/^ '$1'/" Kernel-Infrastructure.st.bak >Kernel-Infrastructure.st
+sed -e "/^version\$/,/^\! \!\$/ s/\^ '[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\(-pre\)\{0,1\}'\$/^ '$VERSION'/" Kernel-Infrastructure.st.bak >Kernel-Infrastructure.st
 rm Kernel-Infrastructure.st.bak
-cd ..
-bin/amberc -d -l Kernel-Objects,Kernel-Collections Kernel-Infrastructure.st
-cd st
-mv *.js ../js
-cd ..
+
+# compile Kernel-Infrastructure
+cd $AMBER_BASE
+bin/amberc -D js -l Kernel-Objects,Kernel-Collections st/Kernel-Infrastructure.st
+# set version in all json files (bower, npm)
 for F in *.json; do
   cp $F $F.bak
-  sed -e 's/"version": "[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\(-pre\)\{0,1\}"/"version": "'"$1"'"/' $F.bak >$F
+  sed -e 's/"version": "[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\(-pre\)\{0,1\}"/"version": "'"$VERSION"'"/' $F.bak >$F
   rm $F.bak
 done