[svn:parrot] r48649 - in trunk: config/gen/makefiles tools/dev

plobsing at svn.parrot.org plobsing at svn.parrot.org
Wed Aug 25 04:40:55 UTC 2010


Author: plobsing
Date: Wed Aug 25 04:40:54 2010
New Revision: 48649
URL: https://trac.parrot.org/parrot/changeset/48649

Log:
convert pbc_to_exe over to Getopt;Obj to facilitate adding new options
possibly assists with TT #1398 and TT #1653

Modified:
   trunk/config/gen/makefiles/root.in
   trunk/tools/dev/pbc_to_exe.pir

Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in	Wed Aug 25 00:24:36 2010	(r48648)
+++ trunk/config/gen/makefiles/root.in	Wed Aug 25 04:40:54 2010	(r48649)
@@ -841,7 +841,7 @@
 	@rpath_blib@ $(ALL_PARROT_LIBS) $(LINKFLAGS) $(LINK_DYNAMIC)
 #IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1
 
-$(PBC_TO_EXE) : tools/dev/pbc_to_exe.pir runtime/parrot/library/config.pir $(PARROT) $(DYNEXT_DIR)/os$(LOAD_EXT) $(DYNEXT_DIR)/file$(LOAD_EXT)
+$(PBC_TO_EXE) : tools/dev/pbc_to_exe.pir runtime/parrot/library/config.pir $(PARROT) $(DYNEXT_DIR)/os$(LOAD_EXT) $(DYNEXT_DIR)/file$(LOAD_EXT) $(LIBRARY_DIR)/Getopt/Obj.pbc
 	$(PARROT) -o pbc_to_exe.pbc tools/dev/pbc_to_exe.pir
 	$(PARROT) pbc_to_exe.pbc pbc_to_exe.pbc
 

Modified: trunk/tools/dev/pbc_to_exe.pir
==============================================================================
--- trunk/tools/dev/pbc_to_exe.pir	Wed Aug 25 00:24:36 2010	(r48648)
+++ trunk/tools/dev/pbc_to_exe.pir	Wed Aug 25 04:40:54 2010	(r48649)
@@ -143,49 +143,29 @@
     obj    = $P0['o']
     exe    = $P0['exe']
 
-    .local pmc args
-    args   = argv
+    load_bytecode 'Getopt/Obj.pbc'
+    .local pmc getopt
+    getopt = new ['Getopt';'Obj']
+    push getopt, 'install|i'
+
+    $P0 = shift argv # ignore program name
+    .local pmc opts
+    opts = getopt.'get_options'(argv)
+    .local string infile
+    infile = shift argv
 
-    .local int argc
-    argc = args
-
-    if argc == 2 goto proper_args
-    if argc == 3 goto check_install
-    .return ()
-
-  check_install:
-    .local string infile, install
-
-    $P0     = shift args
-    infile  = shift args
-    install = shift args
-    if install == '--install' goto proper_install
-    .return ()
-
-  proper_install:
+    # substitute .c for .pbc
+    # remove .c for executable
     .local string cfile, objfile, exefile
-
-    cfile   = 'replace_pbc_extension'(infile, '.c')
-    objfile = 'replace_pbc_extension'(infile, obj)
-    $S0     = 'replace_pbc_extension'(infile, exe)
-    exefile = 'prepend_installable'($S0)
-
-    .return(infile, cfile, objfile, exefile)
-
-  proper_args:
-
-    $P0    = shift args
-    infile = shift args
-
     cfile   = 'replace_pbc_extension'(infile, '.c')
     objfile = 'replace_pbc_extension'(infile, obj)
     exefile = 'replace_pbc_extension'(infile, exe)
+    $I0 = opts['install']
+    unless $I0 goto end_installable
+        exefile = 'prepend_installable'(exefile)
+    end_installable:
 
-    # substitute .c for .pbc
-    # remove .c for executable
-
-    # TODO this should complain about results/returns mismatch
-    .return(infile, cfile, objfile, exefile)
+    .return (infile, cfile, objfile, exefile)
 .end
 
 .sub 'determine_code_type'


More information about the parrot-commits mailing list