Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cudaup.sh not portable (does not run "out of the box" on freebsd) #11

Open
bogen85 opened this issue Aug 4, 2021 · 5 comments
Open

Comments

@bogen85
Copy link

bogen85 commented Aug 4, 2021

I got cudatext to build on freebsd by hacking cudaup.sh in a non-maintainable way.

diff --git a/cudaup.sh b/cudaup.sh
index 03ba3bd..d418e90 100755
--- a/cudaup.sh
+++ b/cudaup.sh
@@ -1,4 +1,6 @@
-#!/bin/bash
+#!/usr/bin/env bash
+
+set -euo pipefail
 
 #set -e
 OS="linux"
@@ -29,17 +31,17 @@ Options:
 
 [ $# -eq 0 ] && { echo "$usage"; exit 0; }
 
-OPTIONS=hgpml:o:c:w:
-LONGOPTS=clean,help,get,packs,make,lazdir:,os:,cpu:,ws:
-! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
-if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
-       echo "$usage"  
-       exit 2
-fi
-eval set -- "$PARSED"
+#OPTIONS=hgpml:o:c:w:
+#LONGOPTS=clean,help,get,packs,make,lazdir:,os:,cpu:,ws:
+#! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
+#if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
+#      echo "$usage"
+#      exit 2
+#fi
+#eval set -- "$PARSED"
 
 while true; do
-       case "$1" in
+       case "${1:-__NONE__}" in
        --clean)
                DoClean=true
                shift
@@ -80,6 +82,9 @@ while true; do
                shift
                break
                ;;
+       __NONE__)
+               break
+               ;;
        esac
 done
 
@@ -162,7 +167,7 @@ then
                        "$lazdir/lazbuild" $inc -q --lazarusdir="$lazdir" "./src/$i"
                done
        fi
-       rm "./src/CudaText/app/cudatext"
+       rm -f "./src/CudaText/app/cudatext"
        "$lazdir/lazbuild" $inc -q --lazarusdir="$lazdir" "./src/CudaText/app/cudatext.lpi"
        OUTDIR="./bin/$OS-$CPU-$WS"
        mkdir -pv $OUTDIR

Only needed to install a few packages to get the build via ./cudaup.sh -o freebsd -m to complete

sudo pkg ins lazarus-gtk2
sudo pkg ins fpc
sudo pkg ins fpc-fcl-stl
...
(9022) Compiling resource /usr/home/dwight/build/cudatext/CudaText_up/src/CudaText/app/lib/x86_64-freebsd/cudatext.or
(9015) Linking /usr/home/dwight/build/cudatext/CudaText_up/src/CudaText/app/cudatext
(1008) 939 lines compiled, 11.4 sec
(1021) 42 warning(s) issued
(1022) 27 hint(s) issued
(1023) 1 note(s) issued

I would like to fix this and submit a PR that makes cudaup portable on Linux and FreeBSD, but I'd almost prefer to rewrite it in python (so it is not relying on external commands like getopt that may not be portable between Linux and FreeBSD) and just have cudaup.sh be a wrapper for cudaup.py, and determine which python to execute by checking which python versions are installed, and choosing the latest (or something like that, to be determined...).

So I'd like to discuss the most agreeable way to proceed on this.

@Alexey-T
Copy link
Owner

Alexey-T commented Aug 4, 2021

@bogen85 Let's proceed and rewrite it in python.
You can start by creating the CudaText_up_py repo just now.
Let's have the additional cudaup repo. we will merge or not merge it later.

@bogen85
Copy link
Author

bogen85 commented Aug 4, 2021

Alright, sounds good. I'll create my own CudaText_up_py repo and proceed from there.

@bogen85
Copy link
Author

bogen85 commented Aug 8, 2021

@Alexey-T I created CudaText_up_py

It seems to work on FreeBSD and Linux, but I'm sure I have permissions and other issues to work out, plus I've not exercised the "install packages to Lazarus" as I've not make my own custom Lazarus directory.

As such, I would consider this work in progress as I work out any issues.

For now see ./cudaup.sh --help until I get a working README.md

Python to use is automatic, ./cudaup.sh finds a compatible one and uses it (but one can be specified). I will document that in the README.md.

One does not need to be in the CudaText_up_py directory to run the script, one can provide the complete path to the script (the other files/folders it comes with must reside with the the script.) I don't have it working if it is in PATH yet, but I will add the ability to run it from anywhere if it is the PATH.

By default the working directory (where src is created/used) is the current directory, but a different one can be specified.

@Alexey-T Alexey-T reopened this Aug 8, 2021
@Alexey-T
Copy link
Owner

Alexey-T commented Aug 8, 2021

Great! I will try it soon.

@veksha
Copy link
Contributor

veksha commented Jul 30, 2022

Hi, guys. Tried CudaText_up_py for MacOS.

opened an issue here: bogen85/CudaText_up_py#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants