tools.deploy.backend: rearranging the order of parameters in the deploy process, -run needs to be last
							parent
							
								
									e4e6f34f0e
								
							
						
					
					
						commit
						07dd28c94d
					
				| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
USING: kernel pcre sequences tools.deploy.backend tools.test ;
 | 
			
		||||
IN: tools.deploy.backend.tests
 | 
			
		||||
 | 
			
		||||
: complete-match? ( str regexp -- ? )
 | 
			
		||||
    "^" "$" surround matches? ;
 | 
			
		||||
 | 
			
		||||
{ t } [
 | 
			
		||||
    { } staging-command-line
 | 
			
		||||
    {
 | 
			
		||||
        "-staging"
 | 
			
		||||
        "-no-user-init"
 | 
			
		||||
        "-pic=0"
 | 
			
		||||
        "-output-image.*"
 | 
			
		||||
        "-include="
 | 
			
		||||
        "-i=boot\\..*"
 | 
			
		||||
    } [ complete-match? ] 2all?
 | 
			
		||||
] unit-test
 | 
			
		||||
 | 
			
		||||
{ t } [
 | 
			
		||||
    { "compiler" } staging-command-line
 | 
			
		||||
    {
 | 
			
		||||
        "-staging"
 | 
			
		||||
        "-no-user-init"
 | 
			
		||||
        "-pic=0"
 | 
			
		||||
        "-output-image=.*"
 | 
			
		||||
        "-include=compiler"
 | 
			
		||||
        "-i=.*"
 | 
			
		||||
        "-resource-path=.*"
 | 
			
		||||
        "-run=tools.deploy.restage"
 | 
			
		||||
    } [ complete-match? ] 2all?
 | 
			
		||||
] unit-test
 | 
			
		||||
 | 
			
		||||
{ t } [
 | 
			
		||||
    "image" "hello-world" "manifest.file" { "foob" } deploy-command-line
 | 
			
		||||
    {
 | 
			
		||||
        "-pic=0"
 | 
			
		||||
        "-i=.*foob.*"
 | 
			
		||||
        "-vocab-manifest-out=manifest.file"
 | 
			
		||||
        "-deploy-vocab=hello-world"
 | 
			
		||||
        "-deploy-config=.*hello-world"
 | 
			
		||||
        "-output-image=image"
 | 
			
		||||
        "-resource-path=.*"
 | 
			
		||||
        "-run=tools.deploy.shaker"
 | 
			
		||||
    } [ complete-match? ] 2all?
 | 
			
		||||
] unit-test
 | 
			
		||||
| 
						 | 
				
			
			@ -65,29 +65,28 @@ ERROR: can't-deploy-library-file library ;
 | 
			
		|||
    "-" join "." my-arch 3append
 | 
			
		||||
    "staging." ".image" surround cache-file ;
 | 
			
		||||
 | 
			
		||||
DEFER: ?make-staging-image
 | 
			
		||||
 | 
			
		||||
: staging-command-line ( profile -- flags )
 | 
			
		||||
    [
 | 
			
		||||
        "-staging" ,
 | 
			
		||||
        dup empty? [
 | 
			
		||||
            "-i=" my-boot-image-name append ,
 | 
			
		||||
        [
 | 
			
		||||
            "-staging" , "-no-user-init" , "-pic=0" ,
 | 
			
		||||
            [ staging-image-name "-output-image=" prepend , ]
 | 
			
		||||
            [ " " join "-include=" prepend , ] bi
 | 
			
		||||
        ] [
 | 
			
		||||
            dup but-last ?make-staging-image
 | 
			
		||||
            "-resource-path=" "" resource-path append ,
 | 
			
		||||
            "-i=" over but-last staging-image-name append ,
 | 
			
		||||
            "-run=tools.deploy.restage" ,
 | 
			
		||||
        ] if
 | 
			
		||||
        "-output-image=" over staging-image-name append ,
 | 
			
		||||
        "-include=" swap " " join append ,
 | 
			
		||||
        "-no-user-init" ,
 | 
			
		||||
        "-pic=0" ,
 | 
			
		||||
            [ "-i=" my-boot-image-name append , ] [
 | 
			
		||||
                but-last staging-image-name "-i=" prepend ,
 | 
			
		||||
                "-resource-path=" "" resource-path append ,
 | 
			
		||||
                "-run=tools.deploy.restage" ,
 | 
			
		||||
            ] if-empty
 | 
			
		||||
        ] bi
 | 
			
		||||
    ] { } make ;
 | 
			
		||||
 | 
			
		||||
: run-factor ( vm flags -- )
 | 
			
		||||
    swap prefix dup . run-with-output ; inline
 | 
			
		||||
 | 
			
		||||
DEFER: ?make-staging-image
 | 
			
		||||
 | 
			
		||||
: make-staging-image ( profile -- )
 | 
			
		||||
    dup [ but-last ?make-staging-image ] unless-empty
 | 
			
		||||
    vm swap staging-command-line run-factor ;
 | 
			
		||||
 | 
			
		||||
: ?make-staging-image ( profile -- )
 | 
			
		||||
| 
						 | 
				
			
			@ -99,20 +98,17 @@ DEFER: ?make-staging-image
 | 
			
		|||
    [ "deploy-config-" prepend temp-file ] bi
 | 
			
		||||
    [ utf8 set-file-contents ] keep ;
 | 
			
		||||
 | 
			
		||||
: deploy-command-line ( image vocab manifest-file config -- flags )
 | 
			
		||||
: deploy-command-line ( image vocab manifest-file profile -- flags )
 | 
			
		||||
    [
 | 
			
		||||
        bootstrap-profile ?make-staging-image
 | 
			
		||||
        [
 | 
			
		||||
            "-i=" bootstrap-profile staging-image-name append ,
 | 
			
		||||
            "-resource-path=" "" resource-path append ,
 | 
			
		||||
            "-run=tools.deploy.shaker" ,
 | 
			
		||||
            "-vocab-manifest-out=" prepend ,
 | 
			
		||||
            [ "-deploy-vocab=" prepend , ]
 | 
			
		||||
            [ make-deploy-config "-deploy-config=" prepend , ] bi
 | 
			
		||||
            "-output-image=" prepend ,
 | 
			
		||||
            "-pic=0" ,
 | 
			
		||||
        ] { } make
 | 
			
		||||
    ] with-variables ;
 | 
			
		||||
        "-pic=0" ,
 | 
			
		||||
        staging-image-name "-i=" prepend ,
 | 
			
		||||
        "-vocab-manifest-out=" prepend ,
 | 
			
		||||
        [ "-deploy-vocab=" prepend , ]
 | 
			
		||||
        [ make-deploy-config "-deploy-config=" prepend , ] bi
 | 
			
		||||
        "-output-image=" prepend ,
 | 
			
		||||
        "-resource-path=" "" resource-path append ,
 | 
			
		||||
        "-run=tools.deploy.shaker" ,
 | 
			
		||||
    ] { } make ;
 | 
			
		||||
 | 
			
		||||
: parse-vocab-manifest-file ( path -- vocab-manifest )
 | 
			
		||||
    utf8 file-lines [ "empty vocab manifest!" throw ] [
 | 
			
		||||
| 
						 | 
				
			
			@ -123,8 +119,9 @@ DEFER: ?make-staging-image
 | 
			
		|||
 | 
			
		||||
:: make-deploy-image ( vm image vocab config -- manifest )
 | 
			
		||||
    make-boot-image
 | 
			
		||||
    config [ bootstrap-profile ?make-staging-image ] with-variables
 | 
			
		||||
    vocab "vocab-manifest-" prepend temp-file :> manifest-file
 | 
			
		||||
    image vocab manifest-file config deploy-command-line :> flags
 | 
			
		||||
    image vocab manifest-file bootstrap-profile deploy-command-line :> flags
 | 
			
		||||
    vm flags run-factor
 | 
			
		||||
    manifest-file parse-vocab-manifest-file ;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue