[svn:parrot] r42677 - trunk/runtime/parrot/library
fperrad at svn.parrot.org
fperrad at svn.parrot.org
Sat Nov 21 09:34:19 UTC 2009
Author: fperrad
Date: Sat Nov 21 09:34:18 2009
New Revision: 42677
URL: https://trac.parrot.org/parrot/changeset/42677
Log:
[distutils] refactor win32-inno-installer without tools/dev/mk_inno_language.pl
Modified:
trunk/runtime/parrot/library/distutils.pir
Modified: trunk/runtime/parrot/library/distutils.pir
==============================================================================
--- trunk/runtime/parrot/library/distutils.pir Sat Nov 21 08:46:22 2009 (r42676)
+++ trunk/runtime/parrot/library/distutils.pir Sat Nov 21 09:34:18 2009 (r42677)
@@ -1992,8 +1992,6 @@
Only on Windows.
-Currently use the Perl script tools/dev/mk_inno_language.pl
-
=cut
.sub '_win32_inno_installer' :anon
@@ -2015,27 +2013,233 @@
$S1 = 'installable_' . $S0
$S1 .= exe
$S2 = bin . exe
+ $I0 = newer($S2, $S1)
+ if $I0 goto L2
cp($S1, $S2)
goto L2
L1:
- .local string lang
+ $S0 = mk_inno_script(kv :flat :named)
+ spew('inno.iss', $S0)
+
+ system("iscc inno.iss")
+.end
+
+.include 'tm.pasm'
+
+.sub 'mk_inno_script' :anon
+ .param pmc kv :slurpy :named
+ .local pmc config
+ config = get_config()
+
+ $P0 = new 'Hash'
+
+ .local string prefix
+ prefix = config['prefix']
+ $P0['prefix'] = prefix
+
+ .local string version
+ $S1 = config['VERSION']
+ $S2 = config['DEVEL']
+ version = $S1 . $S2
+ $P0['version'] = version
+
+ .local string project
$S0 = cwd()
- lang = basename($S0)
+ project = basename($S0)
+ $P0['project'] = project
- .local string cmd
- cmd = "perl -I"
- $S0 = get_libdir()
- cmd .= $S0
- cmd .= "/tools/lib "
- cmd .= $S0
- cmd .= "/tools/dev/mk_inno_language.pl "
- cmd .= lang
- system(cmd)
+ .local string date
+ $I0 = time
+ $P1 = decodetime $I0
+ $P2 = new 'FixedIntegerArray'
+ set $P2, 3
+ $I0 = $P1[.TM_YEAR]
+ $P2[0] = $I0
+ $I0 = $P1[.TM_MON]
+ $P2[1] = $I0
+ $I0 = $P1[.TM_MDAY]
+ $P2[2] = $I0
+ date = sprintf "%04d%02d%02d", $P2
+ $P0['date'] = date
+
+ .local string license
+ $I0 = file_exists('LICENSE')
+ unless $I0 goto L11
+ license = "LicenseFile=LICENSE"
+ goto L19
+ L11:
+ $I0 = file_exists('COPYING')
+ unless $I0 goto L12
+ license = "LicenseFile=COPYING"
+ goto L19
+ L12:
+ $I0 = file_exists('COPYRIGHT')
+ unless $I0 goto L13
+ license = "LicenseFile=COPYRIGHT"
+ goto L19
+ L13:
+ license = "; no LicenseFile"
+ L19:
+ $P0['license'] = license
+
+ $S0 = <<'TEMPLATE'
+; generated by distutils.pir for the Inno Setup Script Compiler.
+
+[Setup]
+AppName=Parrot-$project
+AppVerName=Parrot-$version-$project-$date
+AppPublisher=Parrot Foundation
+AppPublisherURL=http://www.parrot.org/
+DefaultDirName={sd}$prefix
+DefaultGroupName=Parrot
+AllowNoIcons=yes
+$license
+OutputDir=.\\
+OutputBaseFilename=setup-parrot-$version-$project-$date
+Compression=lzma
+SolidCompression=yes
+Uninstallable=no
+
+[Files]
+TEMPLATE
+ .local string script
+ script = interpolate($S0, $P0)
+
+ $I0 = exists kv['dynops']
+ if $I0 goto L21
+ $I0 = exists kv['dynpmc']
+ if $I0 goto L21
+ goto L22
+ L21:
+ script .= "Source: \".\\dynext\\*.dll\"; DestDir: \"{app}\\lib\\parrot\\dynext\"; Flags:\n"
+ L22:
- cmd = "iscc parrot-" . lang
- cmd .= ".iss"
- system(cmd)
+ $I0 = exists kv['installable_pbc']
+ unless $I0 goto L23
+ $P1 = kv['installable_pbc']
+ $P2 = iter $P1
+ L24:
+ unless $P2 goto L23
+ $S0 = shift $P2
+ script .= "Source: \".\\"
+ script .= $S0
+ script .= ".exe\"; DestDir: \"{app}\\bin\"; Flags:\n"
+ goto L24
+ L23:
+
+ $I0 = exists kv['inst_lang']
+ unless $I0 goto L31
+ $P1 = kv['inst_lang']
+ $I0 = does $P1, 'array'
+ if $I0 goto L32
+ $S1 = $P1
+ $S0 = _mk_inno_line('languages', $S1)
+ script .= $S0
+ goto L31
+ L32:
+ $P2 = iter $P1
+ L33:
+ unless $P2 goto L31
+ $S1 = shift $P2
+ $S0 = _mk_inno_line('languages', $S1)
+ script .= $S0
+ goto L33
+ L31:
+
+ $I0 = exists kv['inst_lib']
+ unless $I0 goto L41
+ $P1 = kv['inst_lib']
+ $I0 = does $P1, 'array'
+ if $I0 goto L42
+ $S1 = $P1
+ $S0 = _mk_inno_line('library', $S1)
+ script .= $S0
+ goto L41
+ L42:
+ $P2 = iter $P1
+ L43:
+ unless $P2 goto L41
+ $S1 = shift $P2
+ $S0 = _mk_inno_line('library', $S1)
+ script .= $S0
+ goto L43
+ L41:
+
+ script .= "\n"
+ .return (script)
+.end
+
+.sub '_mk_inno_line' :anon
+ .param string dest
+ .param string filename
+ .local string line
+ line = "Source: \".\\"
+ $S0 = _escape_path_win32(filename)
+ line .= $S0
+ line .= "\"; DestDir: \"{app}\\lib\\parrot\\"
+ line .= dest
+ line .= "\\"
+ $S0 = dirname(filename)
+ $S0 = _escape_path_win32($S0)
+ line .= $S0
+ line .= "\"; Flags:\n"
+ .return (line)
+.end
+
+.sub '_escape_path_win32' :anon
+ .param string path
+ $P0 = split "/", path
+ $S0 = join "\\", $P0
+ .return ($S0)
+.end
+
+.include 'cclass.pasm'
+
+.sub 'interpolate' :anon
+ .param string content
+ .param pmc config
+ $P0 = split "\n", content
+ .local string result, line
+ result = ''
+ L1:
+ unless $P0 goto L2
+ line = shift $P0
+ $I9 = length line
+ $I0 = 0
+ $S0 = ''
+ L3:
+ $I1 = index line, '$', $I0
+ if $I1 < 0 goto L4
+ L8:
+ $I2 = $I1 - $I0
+ inc $I1
+ $I3 = find_not_cclass .CCLASS_WORD, line, $I1, $I9
+# if $I3 < 0 goto L4
+ $S1 = substr line, $I0, $I2
+ $S0 .= $S1
+ $I4 = $I3 - $I1
+ $S1 = substr line, $I1, $I4
+ $I7 = exists config[$S1]
+ unless $I7 goto L5
+ $S2 = config[$S1]
+ $S0 .= $S2
+ goto L6
+ L5:
+ printerr "\tunknown config: "
+ printerr $S1
+ printerr "\n"
+ L6:
+ $I0 = $I3
+ goto L3
+ L4:
+ $S1 = substr line, $I0
+ $S0 .= $S1
+ result .= $S0
+ result .= "\n"
+ goto L1
+ L2:
+ .return (result)
.end
=head3 Configuration Helpers
@@ -2467,6 +2671,57 @@
$P0[name] = value
.end
+=item slurp
+
+=cut
+
+.sub 'slurp' :anon
+ .param string filename
+ $P0 = new 'FileHandle'
+ push_eh _handler
+ $S0 = $P0.'readall'(filename)
+ pop_eh
+ .return ($S0)
+ _handler:
+ .local pmc e
+ .get_results (e)
+ $S0 = "Can't open '"
+ $S0 .= filename
+ $S0 .= "' ("
+ $S1 = err
+ $S0 .= $S1
+ $S0 .= ")\n"
+ e = $S0
+ rethrow e
+.end
+
+=item spew
+
+=cut
+
+.sub 'spew' :anon
+ .param string filename
+ .param string content
+ $P0 = new 'FileHandle'
+ push_eh _handler
+ $P0.'open'(filename, 'w')
+ pop_eh
+ $P0.'puts'(content)
+ $P0.'close'()
+ .return ()
+ _handler:
+ .local pmc e
+ .get_results (e)
+ $S0 = "Can't open '"
+ $S0 .= filename
+ $S0 .= "' ("
+ $S1 = err
+ $S0 .= $S1
+ $S0 .= ")\n"
+ e = $S0
+ rethrow e
+.end
+
=back
=head2 SEE ALSO
More information about the parrot-commits
mailing list