Skip to content

Commit

Permalink
Merge pull request #64 from PerryWerneck/macos
Browse files Browse the repository at this point in the history
Merging macos fixes into develop branch.
  • Loading branch information
PerryWerneck committed Mar 3, 2024
2 parents 9ca97aa + 661afc0 commit 94210aa
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 5 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/macpkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish
on:
push:
branches:
- macos
pull_request:
branches:
- master
- develop
jobs:
macos:
name: Publish macos
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: oprypin/find-latest-tag@v1
id: gettag
with:
repository: PerryWerneck/pw3270
sort-tags: true
releases-only: true
- name: Install Pre reqs
run: |
brew update
brew install xz automake libtool binutils coreutils curl gettext libtool openssl pkgconfig gtk+3
brew upgrade
- uses: robinraju/release-downloader@v1.7
with:
repository: "PerryWerneck/lib3270"
latest: true
fileName: "macos-lib3270.tar.xz"
- uses: robinraju/release-downloader@v1.7
with:
repository: "PerryWerneck/libv3270"
latest: true
fileName: "macos-libv3270.tar.xz"
- name: build
run: ./mac/ci-build.sh
- uses: ncipollo/release-action@v1
with:
tag: ${{ steps.gettag.outputs.tag }}
artifacts: "macos-pw3270.tar.xz"
allowUpdates: true
draft: true
makeLatest: true
omitBody: true
omitPrereleaseDuringUpdate: true
replacesArtifacts: true

20 changes: 15 additions & 5 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ cd ${srcdir}
mkdir -p ./scripts
mkdir -p m4

libtoolize --force
if test $? != 0 ; then
echo "libtoolize failed."
exit -1
fi
case `uname` in
Darwin*)
glibtoolize --force
if test $? != 0 ; then
echo "glibtoolize failed."
exit -1
fi
;;
*)
libtoolize --force
if test $? != 0 ; then
echo "libtoolize failed."
exit -1
fi
esac

aclocal
if test $? != 0 ; then
Expand Down
37 changes: 37 additions & 0 deletions mac/ci-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

PROJECT_NAME=$(grep AC_INIT configure.ac | cut -d[ -f2 | cut -d] -f1)
VERSION=$(grep AC_INIT configure.ac | cut -d[ -f3 | cut -d] -f1)

unpack() {

echo "Unpacking ${1}"

tar -C $(brew --cellar) -Jxvf macos-${1}.tar.xz
if [ "$?" != "0" ]; then
exit -1
fi

brew link ${1}
if [ "$?" != "0" ]; then
exit -1
fi

}

unpack lib3270
unpack libv3270

./autogen.sh --prefix="/${PROJECT_NAME}/${VERSION}"
if [ "$?" != "0" ]; then
exit -1
fi

make all
if [ "$?" != "0" ]; then
exit -1
fi

make DESTDIR=.bin/package install
tar --create --xz --file=macos-${PROJECT_NAME}.tar.xz --directory=.bin/package --verbose .

3 changes: 3 additions & 0 deletions pw3270.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
<Unit filename="src/main/linux/tools.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="src/main/macos/tools.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="src/main/main.c">
<Option compilerVar="CC" />
</Unit>
Expand Down
83 changes: 83 additions & 0 deletions src/main/macos/tools.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */

/*
* Copyright (C) <2008> <Banco do Brasil S.A.>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <config.h>
#include <pw3270.h>
#include <sys/syslimits.h>
#include <CoreFoundation/CFBundle.h>
#include <CoreFoundation/CFURL.h>

static gchar * get_path_from_bundle(const char *name, GFileTest test) {

size_t szBuffer = PATH_MAX;
char buffer[PATH_MAX+1];
memset(buffer,0,PATH_MAX+1);

CFBundleRef mainBundle = CFBundleGetMainBundle();

if (mainBundle) {

CFURLRef url = CFBundleCopyBundleURL(mainBundle);

if (url) {

CFURLGetFileSystemRepresentation(url, true, (UInt8 *) buffer, szBuffer);
CFRelease(url);

gchar * path = g_build_filename(buffer,name,NULL);

if(g_file_test(path,test)) {
return path;
}

g_free(path);

}

}

return NULL;

}

gchar * pw3270_build_data_path(const char *name) {

gchar * path = get_path_from_bundle(name,G_FILE_TEST_IS_DIR);

if(path) {
return path;
}

g_message("Cant find path for '%s'",path);
return NULL;

}

gchar * pw3270_build_data_filename(const char *filename) {

gchar * path = get_path_from_bundle(filename,G_FILE_TEST_IS_REGULAR);

if(path) {
return path;
}

g_error("Cant find '%s'",filename);
return NULL;
}

0 comments on commit 94210aa

Please sign in to comment.