]> gitweb.factorcode.org Git - factor.git/commitdiff
build-from-source: use a pristine directory $TEMP/github/[org]/[repo]
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 27 Apr 2023 22:53:37 +0000 (17:53 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 27 Apr 2023 22:58:11 +0000 (17:58 -0500)
add support for gitlab (freedesktop cairo moved there only)

extra/build-from-source/build-from-source.factor
extra/build-from-source/macosx/macosx.factor
extra/build-from-source/windows/windows.factor

index f005193278c436d6472d7544f6345f13f981b8b1..f29912df2a3401e617637d841fe33be9b4fe0247 100644 (file)
@@ -1,13 +1,17 @@
 ! Copyright (C) 2023 Doug Coleman.
 ! See https://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs cli.git combinators
-combinators.short-circuit continuations formatting github
-http.client io.directories io.files io.files.info io.files.temp
-io.launcher io.pathnames json kernel layouts math namespaces
-semver sequences sequences.extras sorting sorting.human
-sorting.specification splitting system unicode ;
+combinators.extras combinators.short-circuit continuations
+formatting github http.client io.directories io.files
+io.files.info io.files.temp io.launcher io.pathnames json kernel
+layouts math namespaces namespaces.extras semver sequences
+sequences.extras sorting sorting.human sorting.specification
+splitting system unicode ;
 IN: build-from-source
 
+INITIALIZED-SYMBOL: use-gitlab-git-uris [ f ]
+INITIALIZED-SYMBOL: use-github-git-uris [ t ]
+
 : dll-out-directory ( -- path )
     vm-path parent-directory cell-bits "dlls%s-out" sprintf append-path
     dup make-directories ;
@@ -48,31 +52,79 @@ ERROR: no-output-file path ;
 
 : with-build-directory ( quot -- ) [ "build" ] dip with-build-directory-as ; inline
 
-: empty-directory? ( path -- ? )
-    { [ directory? ] [ directory-files empty? ] } 1&& ;
-
-! Windows clears the Factor temp directory but leaves the directory names (?)
-! C:\Users\sheeple\AppData\Local\Temp\factorcode.org\Factor>
-: ?sync-repository-as ( url path -- )
-    dup { [ git-directory? ] [ ".git" append-path empty-directory? not ] } 1&&
-    [ dup ?delete-tree ] unless
-    sync-repository-as wait-for-success ;
-
 : temp-directory-cpu ( -- path )
     temp-directory cpu name>> append-path ;
 
 : with-temp-cpu-directory ( quot -- )
-    [ temp-directory-cpu ] dip with-directory ; inline
+    [ temp-directory-cpu dup make-directories ] dip with-directory ; inline
+
+: temp-directory-gitlab ( -- path )
+    temp-directory "gitlab" append-path ;
+
+: with-temp-gitlab-org-directory ( base org/user quot -- )
+    [ append-path temp-directory-gitlab prepend-path dup make-directories ] dip with-directory ; inline
+
+: gitlab-git-uri ( base org/user project -- uri ) "git://%s/%s/%s" sprintf ;
+: gitlab-http-uri ( base org/user project -- uri ) "http://%s/%s/%s" sprintf ;
+: gitlab-https-uri ( base org/user project -- uri ) "https://%s/%s/%s" sprintf ;
 
-: with-updated-git-repo-as ( git-uri path quot -- )
-    temp-directory-cpu make-directories
+: gitlab-uri ( base org/user project -- uri )
+    use-gitlab-git-uris get [ gitlab-git-uri ] [ gitlab-https-uri ] if ;
+
+! "gitlab.freedesktop.org" "cairo" "cairo"
+: sync-gitlab-pristine-repository-as ( base org/user project -- )
+    [ drop ] [ gitlab-uri ] 3bi
     '[
-        _ _ [ ?sync-repository-as ] keep
-        prepend-current-path _ with-directory
+        _ sync-repository wait-for-success
+    ] with-temp-gitlab-org-directory ;
+
+: sync-gitlab-pristine-and-clone-build-repository-as ( base org/user project build-path -- build-path )
+    [ drop sync-gitlab-pristine-repository-as ]
+    [ [ append-path append-path temp-directory-gitlab prepend-path ] dip ] 4bi
+    '[
+        _ _ [ ?delete-tree ] [ git-clone-as wait-for-success ] [ ] tri
+    ] with-temp-cpu-directory ;
+
+: with-updated-gitlab-repo-as ( base org/user project build-path-as quot -- )
+    [ sync-gitlab-pristine-and-clone-build-repository-as ] dip
+    '[
+        _ prepend-current-path _ with-directory
+    ] with-temp-cpu-directory ; inline
+
+: with-updated-gitlab-repo ( base org/user project quot -- )
+    [ dup git-directory-name ] dip with-updated-gitlab-repo-as ; inline
+
+: temp-directory-github ( -- path )
+    temp-directory "github" append-path ;
+
+: with-temp-github-directory ( org/user quot -- )
+    [ temp-directory-github prepend-path dup make-directories ] dip with-directory ; inline
+
+: github-uri ( org/user project -- uri )
+    use-github-git-uris get [ github-git-uri ] [ github-https-uri ] if ;
+
+: sync-github-pristine-repository-as ( org/user project -- )
+    [ drop ] [ github-uri ] [ nip ] 2tri
+    '[
+        _ _ sync-repository-as wait-for-success
+    ] with-temp-github-directory ;
+
+! "factor" "vscode-factor" "factor-buildme-here"
+: sync-github-pristine-and-clone-build-repository-as ( org/user project build-path -- build-path )
+    [ drop sync-github-pristine-repository-as ]
+    [ [ append-path temp-directory-github prepend-path ] dip ] 3bi
+    '[
+        _ _ [ ?delete-tree ] [ git-clone-as wait-for-success ] [ ] tri
+    ] with-temp-cpu-directory ;
+
+: with-updated-github-repo-as ( org/user project build-path-as quot -- )
+    [ sync-github-pristine-and-clone-build-repository-as ] dip
+    '[
+        _ prepend-current-path _ with-directory
     ] with-temp-cpu-directory ; inline
 
-: with-updated-git-repo ( git-uri quot -- )
-    [ dup git-directory-name ] dip with-updated-git-repo-as ; inline
+: with-updated-github-repo ( org/user project quot -- )
+    [ dup git-directory-name ] dip with-updated-github-repo-as ; inline
 
 : ?download ( path -- )
     dup file-name file-exists? [ drop ] [ download ] if ; inline
index 8615e89ae6e551cc6499b7acff1b3b4691dedea8..0f79aa919150889f77482350457aa54a62b4f68c 100644 (file)
@@ -7,7 +7,7 @@ IN: build-from-source.macosx
 
 ! brew install pkg-config openssl@1.1 xz gdbm tcl-tk
 : build-python3-lib ( -- )
-    "https://github.com/python/cpython" "cpython3" [
+    "python" "cpython" "cpython3" [
         latest-python3 git-checkout-existing* drop
         H{ } clone
         { "brew" "--prefix" "gdbm" } process-contents
@@ -23,4 +23,4 @@ IN: build-from-source.macosx
             "--with-openssl=%s" sprintf suffix
         >>command try-process
         { "make" "-j" } try-process
-    ] with-updated-git-repo-as ;
+    ] with-updated-github-repo-as ;
index e5dbd830b2dd6a92b1ee89a005ed8e38bd6d8a4e..0b1dbcfa735a77eb7753b9e9e6356d8233fa72d5 100644 (file)
@@ -50,17 +50,17 @@ IN: build-from-source.windows
     ] with-tar-gz ;
 
 : build-winflexbison ( -- )
-    "https://github.com/lexxmark/winflexbison.git" [
+    "lexxmark" "winflexbison" [
         [
             qw{ cmake .. } try-process
             qw{ cmake --build . --config Release --target package } try-process
         ] with-build-directory
         "bin/Release/win_bison.exe" "bison.exe" copy-vm-file-as
         "bin/Release/win_flex.exe" "flex.exe" copy-vm-file-as
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 : build-blas ( -- )
-    "https://github.com/xianyi/OpenBLAS.git" [
+    "xianyi" "OpenBLAS" [
         [
             32-bit? [
                 { "cmake" "-G" "Visual Studio 17 2022" "-A" "Win32" "-DCMAKE_BUILD_TYPE=Release" "-DBUILD_SHARED_LIBS=ON" ".." } try-process
@@ -71,10 +71,10 @@ IN: build-from-source.windows
             ] if
             "lib/RELEASE/openblas.dll" "blas.dll" copy-output-file-as
         ] with-build-directory
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 : build-openssl-32-dlls ( -- )
-    "http://github.com/openssl/openssl.git" [
+    "openssl" "openssl" [
         check-perl
         "ProgramW6432" os-env program-files or
             "NASM/nasm.exe" append-path "nasm.exe" prepend-current-path copy-file
@@ -83,10 +83,10 @@ IN: build-from-source.windows
         qw{ perl Configure -DOPENSSL_PIC VC-WIN32 /FS } try-process
         have-jom? qw{ jom -j 32 } { "nmake" } ? try-process
         { "libssl-3.dll" "libcrypto-3.dll" } copy-output-files
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 : build-openssl-64-dlls ( -- )
-    "https://github.com/openssl/openssl.git" [
+    "openssl" "openssl" [
         check-perl
         program-files "NASM/nasm.exe" append-path "nasm.exe" prepend-current-path copy-file
         check-nasm
@@ -94,13 +94,13 @@ IN: build-from-source.windows
         qw{ perl Configure -DOPENSSL_PIC VC-WIN64A /FS } try-process
         have-jom? qw{ jom -j 32 } { "nmake" } ? try-process
         { "apps/libssl-3-x64.dll" "apps/libcrypto-3-x64.dll" } copy-output-files
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 : build-openssl-dlls ( -- )
     32-bit? [ build-openssl-32-dlls ] [ build-openssl-64-dlls ] if ;
 
 : build-cairo-dll ( -- )
-    "https://github.com/freedesktop/cairo.git" [
+    "gitlab.freedesktop.org" "cairo" "cairo" [
         qw{ meson setup --force-fallback-for=freetype2,fontconfig,zlib,expat,expat_dep build } try-process
         "build" prepend-current-path
         [ { "ninja" } try-process ] with-directory
@@ -114,7 +114,7 @@ IN: build-from-source.windows
             "testmodulea.dll"
             "testmoduleb.dll"
         } delete-output-files
-    ] with-updated-git-repo ;
+    ] with-updated-gitlab-repo ;
 
 : latest-libressl ( -- path )
     "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/" [
@@ -144,7 +144,7 @@ IN: build-from-source.windows
     ] with-tar-gz ;
 
 : build-openal-dll ( -- )
-    "https://github.com/kcat/openal-soft.git" [
+    "kcat" "openal-soft" [
         [
             32-bit? [
                 {
@@ -166,7 +166,7 @@ IN: build-from-source.windows
             ] if
             "Release/OpenAL32.dll" copy-output-file
         ] with-build-directory
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 : latest-pcre-tar-gz ( -- path )
     "https://ftp.exim.org/pub/pcre/" [
@@ -191,7 +191,7 @@ IN: build-from-source.windows
     ] with-tar-gz ;
 
 : build-pcre2-dll ( -- )
-    "https://github.com/PCRE2Project/pcre2.git" [
+    "PCRE2Project" "pcre2" [
         [
             32-bit? [
                 qw{ cmake -A Win32 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DPCRE2_SUPPORT_UNICODE=ON -DPCRE2_SUPPORT_LIBZ=OFF -DPCRE2_SUPPORT_LIBBZ2=OFF -DPCRE2_SUPPORT_LIBEDIT=OFF -DPCRE2_SUPPORT_LIBREADLINE=OFF .. } try-process
@@ -202,21 +202,21 @@ IN: build-from-source.windows
             ] if
             { "Release/pcre2-8.dll" "Release/pcre2-posix.dll" } copy-output-files
         ] with-build-directory
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 ! choco install -y meson winflexbison3
 : build-postgres-dll ( -- )
-    "https://github.com/postgres/postgres" [
+    "postgres" "postgres" [
         "src/tools/msvc/clean.bat" prepend-current-path try-process
         qw{ meson setup build } try-process
         "build" prepend-current-path
         [ { "ninja" } try-process ] with-directory
         "build/src/interfaces/libpq/libpq.dll" copy-output-file
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 ! choco install -y glfw3
 : build-raylib-dll ( -- )
-    "https://github.com/raysan5/raylib.git" [
+    "raysan5" "raylib" [
         [
             32-bit? [
                 qw{ cmake -A Win32 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_EXAMPLES=OFF -DUSE_EXTERNAL_GLFW=OFF .. } try-process
@@ -227,10 +227,10 @@ IN: build-from-source.windows
             ] if
             "raylib/Release/raylib.dll" copy-output-file
         ] with-build-directory
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 : build-raygui-dll ( -- )
-    "https://github.com/raysan5/raygui.git" [
+    "raysan5" "raygui" [
         "src/raygui.h" "src/raygui.c" copy-file
         32-bit? [
             qw{ cl /O2 /I ../raylib/src/ /D_USRDLL /D_WINDLL /DRAYGUI_IMPLEMENTATION /DBUILD_LIBTYPE_SHARED src/raygui.c /LD /Feraygui.dll /link /LIBPATH ../raylib/build/raylib/Release/raylib.lib /subsystem:windows /machine:x86 } try-process
@@ -238,10 +238,10 @@ IN: build-from-source.windows
             qw{ cl /O2 /I ../raylib/src/ /D_USRDLL /D_WINDLL /DRAYGUI_IMPLEMENTATION /DBUILD_LIBTYPE_SHARED src/raygui.c /LD /Feraygui.dll /link /LIBPATH ../raylib/build/raylib/Release/raylib.lib /subsystem:windows /machine:x64 } try-process
         ] if
         "raygui.dll" copy-output-file
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 : build-snappy-dll ( -- )
-    "https://github.com/google/snappy.git" [
+    "google" "snappy" [
         [
             32-bit? [
                 qw{ cmake -A Win32 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DSNAPPY_BUILD_TESTS=OFF -DSNAPPY_BUILD_BENCHMARKS=OFF .. } try-process
@@ -252,17 +252,17 @@ IN: build-from-source.windows
             ] if
             "Release/snappy.dll" copy-output-file
         ] with-build-directory
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 : build-sqlite3-dll ( -- )
-    "https://github.com/sqlite/sqlite.git" [
+    "sqlite" "sqlite" [
         qw{ nmake /f Makefile.msc clean } try-process
         qw{ nmake /f Makefile.msc } try-process
         "sqlite3.dll" copy-output-file
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 : build-yaml-dll ( -- )
-    "https://github.com/yaml/libyaml.git" [
+    "yaml" "libyaml" [
         [
             32-bit? [
                 qw{ cmake -DBUILD_SHARED_LIBS=ON -A Win32 .. } try-process
@@ -274,10 +274,10 @@ IN: build-from-source.windows
 
             "Release/yaml.dll" copy-output-file
         ] with-build-directory
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 : build-zeromq-dll ( -- )
-    "https://github.com/zeromq/libzmq.git" [
+    "zeromq" "libzmq" [
         [
             32-bit? [
                 qw{ cmake -DBUILD_SHARED_LIBS=ON -A Win32 .. } try-process
@@ -288,17 +288,17 @@ IN: build-from-source.windows
             ] if
             "bin/Release" find-dlls first "libzmq.dll" copy-output-file-as
         ] with-build-directory
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 : build-zlib-dll ( -- )
-    "https://github.com/madler/zlib" [
+    "madler" "zlib" [
         qw{ nmake /f win32/Makefile.msc clean } try-process
         qw{ nmake /f win32/Makefile.msc } try-process
         "zlib1.dll" copy-output-file
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 : build-lz4 ( -- )
-    "https://github.com/lz4/lz4.git" [
+    "lz4" "lz4" [
         "build/cmake" [
             [
                 32-bit? [
@@ -311,10 +311,10 @@ IN: build-from-source.windows
                 "Release/lz4.dll" copy-output-file
             ] with-build-directory
         ] with-directory
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 : build-zstd-dll ( -- )
-    "https://github.com/facebook/zstd.git" [
+    "facebook" "zstd" [
         32-bit? [
             qw{
                 meson setup
@@ -349,7 +349,7 @@ IN: build-from-source.windows
             { "ninja" } try-process
             "lib/zstd-1.dll" copy-output-file
         ] with-directory
-    ] with-updated-git-repo ;
+    ] with-updated-github-repo ;
 
 ! Probably not needed on Windows 10+
 : install-windows-redistributable ( -- )
@@ -360,6 +360,7 @@ IN: build-from-source.windows
 
 : build-windows-dlls ( -- )
     dll-out-directory make-directories
+    build-winflexbison
     build-cairo-dll
     build-openssl-dlls
     build-blas