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

Native macOS builds #58

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions build_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/bin/bash
set -e
cl()("$@" 2>&1>&3|sed $'s,.*,\e[31m&\e[m,'>&2)3>&1

if [ "$#" -ne 0 ]; then
BUILD_EXPERIMETAL=1
fi

BUILD_DIR=`pwd`/build_all
INSTALL_DIR=`pwd`/install_all
pushd .
if [ -d "$BUILD_DIR" ]; then rm -rf $BUILD_DIR; fi
mkdir -p $BUILD_DIR

if [ -d "$INSTALL_DIR" ]; then rm -rf $INSTALL_DIR; fi
mkdir -p $INSTALL_DIR/lib $INSTALL_DIR/include


echo -e "\033[1;32m ---------------------- update and install packages ---------------------- \033[0m"
#brew stuff
#brew install wxwidgets
#brew install openal-soft
#brew install cmake
#brew install doxygen
#brew tap osx-cross/homebrew-avr
#brew install avr-gcc

echo -e "\033[1;32m ---------------------- download deps -------------------------------------\033[0m"

cd $BUILD_DIR
git clone --depth=1 https://github.com/lcgamboa/picsim.git
git clone --depth=1 https://github.com/lcgamboa/lxrad.git
#git clone --depth=1 https://github.com/lcgamboa/tty0tty.git
git clone --depth=1 https://github.com/lcgamboa/simavr.git
git clone --depth=1 https://github.com/lcgamboa/uCsim_picsimlab.git

if [[ -n "$BUILD_EXPERIMETAL" ]]; then
#cl sudo apt-get -y install python libglib2.0-dev libpixman-1-dev libfdt-dev gpsim-dev gpsim \
#ninja-build meson
git clone --depth=1 --no-single-branch https://github.com/lcgamboa/qemu_stm32.git
fi

echo -e "\033[1;32m ---------------------- build and install picsim ------------------------- \033[0m"
cd $BUILD_DIR/picsim
make
#make DESTDIR=$INSTALL_DIR install

echo -e "\033[1;32m ---------------------- build and install lxrad -------------------------- \033[0m"
cd $BUILD_DIR/lxrad
./make_deps.sh
./configure --prefix=$INSTALL_DIR LDFLAGS=-L/usr/local/opt/openal-soft/lib CFLAGS=-I/usr/local/opt/openal-soft/include
make
#make install
cd $BUILD_DIR/lunasvg/build
make DESTDIR=$INSTALL_DIR install

echo -e "\033[1;32m ---------------------- build and install simavr ------------------------- \033[0m"
cd $BUILD_DIR/simavr
# cl make clean;
make build-simavr
# #cl sudo make install-simavr

echo -e "\033[1;32m ---------------------- build and install uCsim -------------------------- \033[0m"
cd $BUILD_DIR/uCsim_picsimlab
./configure --prefix=$INSTALL_DIR
make
#make install
cd picsimlab
make
#make install
popd

if [[ -z "$BUILD_EXPERIMETAL" ]]; then
echo "Skipping qemu"
else
echo -e "\033[1;32m ---------------------- build and install qemu_stm32 --------------------- \033[0m"
cd qemu_stm32
cl git checkout picsimlab
git pull --no-rebase
cl ./build_libqemu-stm32.sh
cd build
cl cp qemu-system-arm qemu-stm32
cl strip qemu-stm32
cl sudo cp qemu-stm32 /usr/bin/
fi

echo -e "\033[1;32m ---------------------- build and install picsimlab ---------------------- \033[0m"
make clean
if [[ -z "$BUILD_EXPERIMETAL" ]]; then
mkdir build_all/picsim/include/picsim
cp build_all/picsim/include/*.* build_all/picsim/include/picsim
mkdir build_all/uCsim_picsimlab/picsimlab/ucsim
cp build_all/uCsim_picsimlab/picsimlab/*.* build_all/uCsim_picsimlab/picsimlab/ucsim
mkdir build_all/simavr/simavr/sim/simavr
cp build_all/simavr/simavr/sim/*.* build_all/simavr/simavr/sim/simavr/

pushd build_all/simavr/simavr
ln -s obj-x86_64-apple-darwin20.6.0 obj-x86_64-linux-gnu
popd

make LIBPATH="../build_all/" FILE=Makefile.macos.static
else
make exp
fi
#make install

#
#user=`whoami`
#cl sudo usermod -a -G dialout $user
#echo -e "\033[1;32m ---------------------- done! -------------------------------------------- \033[0m"
#echo -e "\033[1;32m logout your session and login to use serial \033[0m"
#sudo ldconfig
#if xhost > /dev/null 2>&1 ; then
#cl picsimlab
#fi
#
87 changes: 87 additions & 0 deletions src/Makefile.macos.static
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
include Makefile.Common

CXX = g++

PKG_CONFIG= `pkg-config --cflags glib-2.0`

prefix=$(DESTDIR)/usr

RM= rm -f
CP= cp
MKDIR = mkdir -p

appdir= ${prefix}/share/applications/
sharedir= ${prefix}/share/picsimlab/
execdir= ${prefix}/bin/

#lxrad automatic generated block start, don't edit below!

LIBPATH ?= ../../

override CXXFLAGS+= -I/usr/local/opt/openal-soft/include -I$(LIBPATH)/picsim/include/ -I$(LIBPATH)/lxrad/include/ \
-I$(LIBPATH)/simavr/simavr/sim/ -I$(LIBPATH)/uCsim_picsimlab/picsimlab/

override CXXFLAGS+= -D_ARCH_=\"Linux64_WX\" -D_DATE_=\"${DATE}\"
override CXXFLAGS+= -D_VERSION_=\"$(VERSION)\" -Wall -O2 -D_SHARE_=\"../share/picsimlab/\" `wx-config --cxxflags`
override CXXFLAGS+= -DEXT_BROWSER -flto
#override CXXFLAGS+=-fsanitize=address


LIBS= $(LIBPATH)/picsim/src/libpicsim.a $(LIBPATH)/lxrad/lib/liblxrad.a \
$(LIBPATH)/simavr/simavr/obj-x86_64-linux-gnu/libsimavr.a \
$(LIBPATH)/lunasvg/build/liblunasvg.a \
$(LIBPATH)/uCsim_picsimlab/picsimlab/libucsim.a \
-lopenal `wx-config --libs` `wx-config --libs stc`

exp: LIBS+= -lgpsim

#lxrad automatic generated block end, don't edit above!

all: picsimlab

picsimlab: $(OBJS)
@echo "Linking picsimlab"
@$(CXX) $(CXXFLAGS) $(OBJS) -opicsimlab $(LIBS) -I/usr/local/opt/openal-soft/include -L/usr/local/opt/openal-soft/lib

%.o: %.cc
@echo "Compiling $<"
@$(CXX) -c $(CXXFLAGS) $< -o $@

install: all
install -d $(execdir) $(sharedir) $(appdir)
$(CP) -dvf ../share/picsimlab.desktop ${appdir}
$(CP) -drvf ../share/* ${sharedir}
$(CP) -dvf picsimlab ${execdir}
#xdg-icon-resource install --context mimetypes --size 48 ../share/application-x-picsimlab-workspace.png application-x-picsimlab-workspace
#xdg-mime install --mode system ../share/application-x-picsimlab-workspace.xml
#xdg-mime default picsimlab.desktop application/x-picsimlab-workspace
#update-mime-database /usr/share/mime &
#update-desktop-database ${appdir} &

install_app: all
install -d $(execdir) $(sharedir) $(appdir) ${sharedir}/../icons/hicolor/64x64/apps/ \
${sharedir}/../icons/hicolor/64x64/mimetypes/ ${sharedir}/../mime/application/
$(CP) -dvf ../share/picsimlab.desktop ${appdir}/
$(CP) -drvf ../share/* ${sharedir}
$(CP) -dvf picsimlab ${execdir}
strip ${execdir}picsimlab
$(CP) -drvf ../share/picsimlab.png ${sharedir}/../icons/hicolor/64x64/apps/
$(CP) -drvf ../share/application-x-picsimlab-workspace.png ${sharedir}/../icons/hicolor/64x64/mimetypes/
$(CP) -drvf ../share/application-x-picsimlab-workspace.xml ${sharedir}/../mime/application/x-picsimlab-workspace.xml

install_docs:
$(CP) -drvf ../docs ${sharedir}


uninstall:
$(RM) -drvf ${sharedir}
$(RM) -dvf ${execdir}picsimlab
$(RM) -dvf ${appdir}picsimlab.desktop
#xdg-icon-resource uninstall --context mimetypes --size 48 application-x-picsimlab-workspace
#xdg-mime uninstall --mode system ../share/application-x-picsimlab-workspace.xml

run: all
./picsimlab

clean:
$(RM) picsimlab *.o core */*.o