diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b8dcd37..d54d334 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,12 +13,35 @@ jobs: build-msvc: name: Windows MSVC - runs-on: windows-latest + runs-on: windows-2019 steps: - name: Checkout Files uses: actions/checkout@v4 - name: Setup MSVC uses: microsoft/setup-msbuild@v2 + - name: wxWidgets Cache Key + shell: pwsh + run: echo "WXHASH=$($(git submodule status wx) -replace '\s','')" >> $env:GITHUB_ENV + - name: Cache wxWidgets + id: cache-wx + uses: actions/cache@v4 + with: + path: wxlib + key: wx-msvc-${{ env.WXHASH }} + - name: Build wxWidgets + if: steps.cache-wx.outputs.cache-hit != 'true' + shell: cmd + run: | + echo on + git submodule init + git submodule update --depth 1 + cd wx + git submodule init + git submodule update --depth 1 + cd .. + set WXB_NODEBUG=1 + set WXB_NOPAUSE=1 + wxlib.bat - name: Build 64-bit run: msbuild nsfplay.sln -t:rebuild -property:Configuration=Release -property:Platform=x64 - name: Build 32-bit @@ -58,13 +81,37 @@ jobs: uses: msys2/setup-msys2@v2 with: msystem: UCRT64 - install: make mingw-w64-ucrt-x86_64-gcc mingw-w64-i686-gcc + install: git make mingw-w64-ucrt-x86_64-gcc mingw-w64-i686-gcc mingw-w64-ucrt-x86_64-cmake mingw-w64-i686-cmake + - name: wxWidgets Cache Key + shell: pwsh + run: echo "WXHASH=$($(git submodule status wx) -replace '\s','')" >> $env:GITHUB_ENV + - name: Cache wxWidgets + id: cache-wx + uses: actions/cache@v4 + with: + path: wxlib + key: wx-msys2-${{ env.WXHASH }} + - name: Build wxWidgets + if: steps.cache-wx.outputs.cache-hit != 'true' + shell: msys2 {0} + run: | + export WXL_CMAKEDIR=make64 + make wxlib + export PATH="/mingw32/bin:$PATH" + export WXL_CMAKEDIR=make32 + make wxlib - name: Make 64-bit shell: msys2 {0} - run: export OUTDIR=output/make64 INTDIR=intermediate/make64 ; make cmd gui + run: | + export OUTDIR=output/make64 INTDIR=intermediate/make64 + make cmd nsfplay - name: Make 32-bit shell: msys2 {0} - run: export PATH="/mingw32/bin:$PATH" OUTDIR=output/make32 INTDIR=intermediate/make32 ; make + run: | + export PATH="/mingw32/bin:$PATH" + export WXL_LIBDIR=gcc_lib + export OUTDIR=output/make32 INTDIR=intermediate/make32 + make cmd nsfplay winamp - name: Prepare Artifacts shell: pwsh run: | @@ -89,3 +136,39 @@ jobs: with: name: nsfplay3-win32-mingw--${{ env.BUILD_TAG }} path: artifact32/ + + build-ubuntu: + name: Ubuntu + runs-on: ubuntu-latest + steps: + - name: Checkout Files + uses: actions/checkout@v4 + - name: Setup Ubuntu + run: | + sudo apt-get update + sudo apt-get install git make gcc cmake libgtk-3-dev + - name: wxWidgets Cache Key + run: echo "WXHASH=$(git submodule status wx | tr -d '[:blank:]')" >> $GITHUB_ENV + - name: Cache wxWidgets + id: cache-wx + uses: actions/cache@v4 + with: + path: wxlib + key: wx-ubuntu-${{ env.WXHASH }} + - name: Build wxWidgets + if: steps.cache-wx.outputs.cache-hit != 'true' + run: make wxlib + - name: Make + run: make cmd nsfplay + - name: Prepare Artifacts + run: | + mkdir artifact + cp nsfplay.txt artifact + cp output/make/nsfplay artifact + cp output/make/nsfplac artifact + echo "BUILD_TAG=$(git log -1 --format="%ad--%h" --date=format-local:"%Y-%m-%d-%H%M%S")" >> $GITHUB_ENV + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: nsfplay3-ubuntu--${{ env.BUILD_TAG }} + path: artifact/ diff --git a/.gitignore b/.gitignore index 51d0c04..bc24389 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ intermediate output +wxlib secrets *.user .vs diff --git a/cmd/cmd.cpp b/cmd/cmd.cpp index 6d4b35d..d1170b7 100644 --- a/cmd/cmd.cpp +++ b/cmd/cmd.cpp @@ -5,6 +5,6 @@ int main() { - printf("nsfplaycmd stub\n"); + printf("nsfplac stub\n"); return nsfplaycore::test(); } diff --git a/cmd/makefile b/cmd/makefile index b9922c9..9a3f94a 100644 --- a/cmd/makefile +++ b/cmd/makefile @@ -13,16 +13,18 @@ SRCS = $(wildcard *.cpp) OBJS = $(addprefix $(CMD_INTDIR)/,$(SRCS:.cpp=.o)) DEPS = $(addprefix $(CMD_INTDIR)/,$(SRCS:.cpp=.d)) CORE = ../$(OUTDIR)/$(CORE_NAME)$(LIB_SUFFIX) +CXXFLAGS_ALL = $(CXXFLAGS) $(CXXFLAGS_EXTRA) $(INC_COMMON) +LDFLAGS_ALL = $(LDFLAGS) $(LDFLAGS_EXTRA) $(LDFLAGS_CMD) $(TARGET): $(OBJS) $(CORE) | $(dir $(TARGET)) - $(CXX) -o $(TARGET) $(LDFLAGS) $(LDFLAGS_CMD) $(OBJS) $(CORE) + $(CXX) -o $(TARGET) $(LDFLAGS_ALL) $(OBJS) $(CORE) $(STRIP_DEBUG) $(CMD_INTDIR)/%.d: %.cpp | $(CMD_INTDIR)/ - $(CXX) -M -MM -MF $@ -MT $(CMD_INTDIR)/$(basename $<).o $(CXXFLAGS) -c $< + $(CXX) -M -MM -MF $@ -MT $(CMD_INTDIR)/$(basename $<).o $(CXXFLAGS_ALL) -c $< $(CMD_INTDIR)/%.o: %.cpp $(CMD_INTDIR)/%.d | $(CMD_INTDIR)/ - $(CXX) -o $@ $(CXXFLAGS) -c $< + $(CXX) -o $@ $(CXXFLAGS_ALL) -c $< $(CMD_INTDIR)/: $(MKDIR) $@ diff --git a/core/makefile b/core/makefile index a95d26a..10b7af6 100644 --- a/core/makefile +++ b/core/makefile @@ -11,16 +11,17 @@ default: $(TARGET) SRCS = $(wildcard *.cpp) OBJS = $(addprefix $(CORE_INTDIR)/,$(SRCS:.cpp=.o)) DEPS = $(addprefix $(CORE_INTDIR)/,$(SRCS:.cpp=.d)) +CXXFLAGS_ALL = $(CXXFLAGS) $(CXXFLAGS_EXTRA) $(INC_COMMON) $(TARGET): $(OBJS) | $(dir $(TARGET)) rm -f $(TARGET) $(AR) rcs $(TARGET) $(OBJS) $(CORE_INTDIR)/%.d: %.cpp | $(CORE_INTDIR)/ - $(CXX) -M -MM -MF $@ -MT $(CORE_INTDIR)/$(basename $<).o $(CXXFLAGS) -c $< + $(CXX) -M -MM -MF $@ -MT $(CORE_INTDIR)/$(basename $<).o $(CXXFLAGS_ALL) -c $< $(CORE_INTDIR)/%.o: %.cpp $(CORE_INTDIR)/%.d | $(CORE_INTDIR)/ - $(CXX) -o $@ $(CXXFLAGS) -c $< + $(CXX) -o $@ $(CXXFLAGS_ALL) -c $< $(CORE_INTDIR)/: $(MKDIR) $@ diff --git a/gui/gui.vcxproj b/gui/gui.vcxproj index 0cf51da..44030f7 100644 --- a/gui/gui.vcxproj +++ b/gui/gui.vcxproj @@ -98,12 +98,12 @@ Level4 true - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + __WXMSW__;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) true NotUsing pch.h MultiThreadedDebug - ..\include\ + ..\include\;..\wxlib\include\;..\wxlib\lib\vc_lib\mswud\ true @@ -118,12 +118,12 @@ true true true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + __WXMSW__;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) true NotUsing pch.h MultiThreaded - ..\include\ + ..\include\;..\wxlib\include\;..\wxlib\lib\vc_lib\mswu\ true @@ -138,13 +138,13 @@ Level4 true - _DEBUG;_LIB;%(PreprocessorDefinitions) + __WXMSW__;_DEBUG;_LIB;%(PreprocessorDefinitions) true NotUsing pch.h MultiThreadedDebug - ..\include\ true + ..\include\;..\wxlib\include\;..\wxlib\lib\vc_x64_lib\mswud\ @@ -158,13 +158,13 @@ true true true - NDEBUG;_LIB;%(PreprocessorDefinitions) + __WXMSW__;NDEBUG;_LIB;%(PreprocessorDefinitions) true NotUsing pch.h MultiThreaded - ..\include\ true + ..\include\;..\wxlib\include\;..\wxlib\lib\vc_x64_lib\mswu\ diff --git a/gui/gui.vcxproj.filters b/gui/gui.vcxproj.filters index 88cc0b6..d264bda 100644 --- a/gui/gui.vcxproj.filters +++ b/gui/gui.vcxproj.filters @@ -15,10 +15,7 @@ - - Header Files - - + Header Files @@ -26,8 +23,5 @@ Source Files - - Source Files - \ No newline at end of file diff --git a/gui/makefile b/gui/makefile index 63ee84d..c88a311 100644 --- a/gui/makefile +++ b/gui/makefile @@ -11,16 +11,17 @@ default: $(TARGET) SRCS = $(wildcard *.cpp) OBJS = $(addprefix $(GUI_INTDIR)/,$(SRCS:.cpp=.o)) DEPS = $(addprefix $(GUI_INTDIR)/,$(SRCS:.cpp=.d)) +CXXFLAGS_ALL = $(CXXFLAGS) $(CXXFLAGS_EXTRA) $(INC_COMMON) $(WXL_CXXFLAGS) $(TARGET): $(OBJS) | $(dir $(TARGET)) rm -f $(TARGET) $(AR) rcs $(TARGET) $(OBJS) $(GUI_INTDIR)/%.d: %.cpp | $(GUI_INTDIR)/ - $(CXX) -M -MM -MF $@ -MT $(GUI_INTDIR)/$(basename $<).o $(CXXFLAGS) -c $< + $(CXX) -M -MM -MF $@ -MT $(GUI_INTDIR)/$(basename $<).o $(CXXFLAGS_ALL) -c $< $(GUI_INTDIR)/%.o: %.cpp $(GUI_INTDIR)/%.d | $(GUI_INTDIR)/ - $(CXX) -o $@ $(CXXFLAGS) -c $< + $(CXX) -o $@ $(CXXFLAGS_ALL) -c $< $(GUI_INTDIR)/: $(MKDIR) $@ diff --git a/makefile b/makefile index de4f02d..e56282c 100644 --- a/makefile +++ b/makefile @@ -1,13 +1,9 @@ include makefile.common -.PHONY: default core cmd gui nsfplay winamp install uninstall clean +.PHONY: default core cmd gui wxlib nsfplay winamp install uninstall clean default: core cmd nsfplay -ifeq ($(OS),Windows_NT) -default: winamp -endif - core: $(MAKE) -C core @@ -17,6 +13,9 @@ cmd: core gui: core $(MAKE) -C gui +wxlib: + $(MAKE) -f makefile.wx + nsfplay: core gui $(MAKE) -C nsfplay diff --git a/makefile.common b/makefile.common index 5358bc2..d980c33 100644 --- a/makefile.common +++ b/makefile.common @@ -1,38 +1,105 @@ +# output directories + OUTDIR ?= output/make INTDIR ?= intermediate/make prefix ?= /usr/local/bin +# output binary names + +CORE_NAME ?= nsfcore +CMD_NAME ?= nsfplac +GUI_NAME ?= nsfgui +NSFPLAY_NAME ?= nsfplay +WINAMP_NAME ?= nsfplay + +# tool names + MAKE ?= make CXX ?= g++ AR ?= ar MKDIR ?= mkdir -p -CXXFLAGS += -I../include -O3 -Wall -Werror -g -LDFLAGS += -Wl,--fatal-warnings -g -LDFLAGS_CMD += -LDFLAGS_GUI += -LDFLAGS_NSFPLAY += -LDFLAGS_DLL += +# optimization, can be cleared for debugging purposes -LIB_SUFFIX ?= .a -EXE_SUFFIX ?= .exe -DLL_SUFFIX ?= .dll +OPTIMIZE ?= -O3 -CORE_NAME ?= nsfcore -CMD_NAME ?= nsfplac -GUI_NAME ?= nsfgui -NSFPLAY_NAME ?= nsfplay -WINAMP_NAME ?= nsfplay +# wxWidgets + +WXL_DEBUG ?= 0 +WXL_DIR ?= ../wxlib +WXL_CMAKEDIR ?= make + +ifeq ($(WXL_DEBUG),0) + WXL_DEBUG_SUFFIX ?= +else + WXL_DEBUG_SUFFIX ?= d +endif + +# platform settings + +ifeq ($(OS),Windows_NT) + CXXFLAGS_EXTRA ?= -municode + LDFLAGS_EXTRA ?= -static -static-libgcc -static-libstdc++ + LDFLAGS_CMD ?= -mconsole + LDFLAGS_GUI ?= + LDFLAGS_NSFPLAY ?= -mwindows + LDFLAGS_DLL ?= -mdll + LIB_SUFFIX ?= .a + EXE_SUFFIX ?= .exe + DLL_SUFFIX ?= .dll + WXL_LIBDIR ?= gcc_x64_lib + # wx-config is invalid on MSYS2 if built with cmake + WXL_CONFIG ?= + ifeq ("$(WXL_CONFIG)","") + WXL_CXXFLAGS ?= \ + -D__WXMSW__ \ + -I$(WXL_DIR)/include \ + -I$(WXL_DIR)/lib/$(WXL_LIBDIR)/mswu$(WXL_DEBUG_SUFFIX) + WXL_LIBS ?= \ + -L$(WXL_DIR)/lib/$(WXL_LIBDIR) \ + -lwxmsw32u$(WXL_DEBUG_SUFFIX)_propgrid \ + -lwxmsw32u$(WXL_DEBUG_SUFFIX)_core \ + -lwxbase32u$(WXL_DEBUG_SUFFIX) \ + -lwxpng$(WXL_DEBUG_SUFFIX) \ + -lwxzlib$(WXL_DEBUG_SUFFIX) \ + -lcomctl32 \ + -luuid -lole32 -loleacc -loleaut32 \ + -lversion -lshlwapi -luxtheme -lwinspool + endif +else + CXXFLAGS_EXTRA ?= + LDFLAGS_EXTRA ?= + LDFLAGS_CMD ?= + LDFLAGS_GUI ?= + LDFLAGS_NSFPLAY ?= + LDFLAGS_DLL ?= -shared + LIB_SUFFIX ?= .a + EXE_SUFFIX ?= + DLL_SUFFIX ?= .so + WXL_LIBDIR ?= . + # wx-config + WXL_CONFIG ?= $(WXL_DIR)/$(WXL_CMAKEDIR)/wx-config +endif + +ifneq ("$(WXL_CONFIG)","") + ifneq ("$(wildcard $(WXL_CONFIG))","") + WXL_CXXFLAGS ?= $(shell $(WXL_CONFIG) --cxxflags) + WXL_LIBS ?= $(shell $(WXL_CONFIG) --libs base,core,propgrid) + else + WXL_CXXFLAGS ?= <$(WXL_CONFIG) missing> + WXL_LIBS ?= <$(WXL_CONFIG) missing> + endif +endif + +# common build flags + +CXXFLAGS ?= $(OPTIMIZE) -Wall -Werror -g +LDFLAGS ?= -Wl,--fatal-warnings -g +INC_COMMON ?= -I../include + +# utility to move GCC debug information outside of binaries STRIP_DEBUG = \ objcopy --only-keep-debug $@ $@.debug ; \ strip --strip-debug --strip-unneeded $@ ; \ objcopy --add-gnu-debuglink=$@.debug $@ - -ifeq ($(OS),Windows_NT) -CXXFLAGS += -municode -LDFLAGS += -static-libgcc -LDFLAGS_CMD += -mconsole -LDFLAGS_NSFPLAY += -municode -mwindows -LDFLAGS_DLL += -municode -mdll -endif diff --git a/makefile.wx b/makefile.wx new file mode 100644 index 0000000..4b4f493 --- /dev/null +++ b/makefile.wx @@ -0,0 +1,68 @@ +include makefile.common + +WXSRC ?= wx +WXOUT ?= wxlib +WXCMAKE ?= $(WXL_CMAKEDIR) +WXREL ?= ../../wx + +# default cmake configuration + +WXCONF ?= \ + -DwxBUILD_SHARED=OFF \ + -DwxUSE_UNICODE=ON \ + -DwxUSE_AUI=OFF \ + -DwxUSE_HTML=OFF \ + -DwxUSE_MEDIACTRL=OFF \ + -DwxUSE_OPENGL=OFF \ + -DwxUSE_DEBUGREPORT=OFF \ + -DwxUSE_RIBBON=OFF \ + -DwxUSE_RICHTEXT=OFF \ + -DwxUSE_STC=OFF \ + -DwxUSE_WEBVIEW=OFF \ + -DwxUSE_XRC=OFF \ + -DwxUSE_STL=OFF \ + -DwxUSE_REGEX=OFF \ + -DwxUSE_ZLIB=builtin \ + -DwxUSE_EXPAT=OFF \ + -DwxUSE_LIBJPEG=OFF \ + -DwxUSE_LIBPNG=builtin \ + -DwxUSE_LIBTIFF=OFF \ + -DwxUSE_NANOSVG=OFF \ + -DwxUSE_LIBLZMA=OFF \ + -DwxUSE_WXHTML_HELP=OFF + +# WXCONF_EXTRA can be be used to provide extra configuration + +ifeq ($(OS),Windows_NT) + WXCONF_EXTRA ?= -DwxBUILD_USE_STATIC_RUNTIME=ON +else + WXCONF_EXTRA ?= +endif + +# WXL_DEBUG=1 will build debug libraries instead + +ifeq ($(WXL_DEBUG),0) + WXBUILD_TYPE ?= -DCMAKE_BUILD_TYPE=Release +else + WXBUILD_TYPE ?= -DCMAKE_BUILD_TYPE=Debug +endif + + +.PHONY: default wxlib + +default: wxlib + +submodules: + git submodule init + git submodule update --depth 1 + (cd $(WXSRC) && git submodule init) + (cd $(WXSRC) && git submodule update --depth 1) + +wxlib: submodules + mkdir -p $(WXOUT)/$(WXCMAKE) + (cd $(WXOUT)/$(WXCMAKE) && cmake $(WXREL) $(WXCONF) $(WXCONF_EXTRA) $(WXBUILD_TYPE)) + (cd $(WXOUT)/$(WXCMAKE) && cmake --build .) + (cd $(WXOUT)/$(WXCMAKE) && cmake --install . --prefix ..) + +clean: + rm -f -r $(WXOUT)/$(WXCMAKE) diff --git a/nsfplay/makefile b/nsfplay/makefile index d3be2a6..4cb9d51 100644 --- a/nsfplay/makefile +++ b/nsfplay/makefile @@ -14,20 +14,23 @@ OBJS = $(addprefix $(NSFPLAY_INTDIR)/,$(SRCS:.cpp=.o)) DEPS = $(addprefix $(NSFPLAY_INTDIR)/,$(SRCS:.cpp=.d)) CORE = ../$(OUTDIR)/$(CORE_NAME)$(LIB_SUFFIX) GUI = ../$(OUTDIR)/$(GUI_NAME)$(LIB_SUFFIX) +CXXFLAGS_ALL = $(CXXFLAGS) $(CXXFLAGS_EXTRA) $(INC_COMMON) $(WXL_CXXFLAGS) +LDFLAGS_ALL = $(LDFLAGS) $(LDFLAGS_EXTRA) $(LDFLAGS_NSFPLAY) +LIBS = $(CORE) $(GUI) $(WXL_LIBS) ifeq ($(OS),Windows_NT) OBJS += $(NSFPLAY_INTDIR)/nsfplay_rc.o endif $(TARGET): $(OBJS) $(CORE) $(GUI) | $(dir $(TARGET)) - $(CXX) -o $(TARGET) $(LDFLAGS) $(LDFLAGS_NSFPLAY) $(OBJS) $(CORE) $(GUI) + $(CXX) -o $(TARGET) $(LDFLAGS_ALL) $(OBJS) $(LIBS) $(STRIP_DEBUG) $(NSFPLAY_INTDIR)/%.d: %.cpp | $(NSFPLAY_INTDIR)/ - $(CXX) -M -MM -MF $@ -MT $(NSFPLAY_INTDIR)/$(basename $<).o $(CXXFLAGS) -c $< + $(CXX) -M -MM -MF $@ -MT $(NSFPLAY_INTDIR)/$(basename $<).o $(CXXFLAGS_ALL) -c $< $(NSFPLAY_INTDIR)/%.o: %.cpp $(NSFPLAY_INTDIR)/%.d | $(NSFPLAY_INTDIR)/ - $(CXX) -o $@ $(CXXFLAGS) -c $< + $(CXX) -o $@ $(CXXFLAGS_ALL) -c $< $(NSFPLAY_INTDIR)/nsfplay_rc.o: nsfplay.rc *.ico | $(NSFPLAY_INTDIR)/ windres -i $< -o $@ diff --git a/nsfplay/nsfplay.cpp b/nsfplay/nsfplay.cpp index 97b85bf..eaaccb9 100644 --- a/nsfplay/nsfplay.cpp +++ b/nsfplay/nsfplay.cpp @@ -1,16 +1,17 @@ // stub -#include +#include -int APIENTRY wWinMain(_In_ HINSTANCE hInstance, - _In_opt_ HINSTANCE hPrevInstance, - _In_ LPWSTR lpCmdLine, - _In_ int nCmdShow) +class MainApp : public wxApp { - UNREFERENCED_PARAMETER(hInstance); - UNREFERENCED_PARAMETER(hPrevInstance); - UNREFERENCED_PARAMETER(lpCmdLine); - UNREFERENCED_PARAMETER(nCmdShow); - MessageBox(NULL,L"NSFPlay 3 stub",L"NSFPlay 3",MB_OK); - return 0; +public: + bool OnInit() override; +}; + +wxIMPLEMENT_APP(MainApp); + +bool MainApp::OnInit() +{ + wxMessageBox("NSFPlay 3 stub","NSFPlay 3",wxOK | wxICON_INFORMATION); + return false; } diff --git a/nsfplay/nsfplay.vcxproj b/nsfplay/nsfplay.vcxproj index 5316ab3..b9bb7ad 100644 --- a/nsfplay/nsfplay.vcxproj +++ b/nsfplay/nsfplay.vcxproj @@ -99,16 +99,17 @@ Level4 true - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + __WXMSW__;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true MultiThreadedDebug - ..\include\ + ..\include\;..\wxlib\include\;..\wxlib\lib\vc_lib\mswud\ true Windows true - $(OutDir)nsfcore.lib;$(OutDir)nsfgui.lib;%(AdditionalDependencies) + $(OutDir)nsfcore.lib;$(OutDir)nsfgui.lib;wxmsw32ud_propgrid.lib;wxmsw32ud_core.lib;wxbase32ud.lib;wxpngd.lib;wxzlibd.lib;comctl32.lib;rpcrt4.lib;%(AdditionalDependencies) + ..\wxlib\lib\vc_lib\;%(AdditionalLibraryDirectories) @@ -117,10 +118,10 @@ true true true - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + __WXMSW__;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true MultiThreaded - ..\include\ + ..\include\;..\wxlib\include\;..\wxlib\lib\vc_lib\mswu\ true @@ -128,23 +129,25 @@ true true true - $(OutDir)nsfcore.lib;$(OutDir)nsfgui.lib;%(AdditionalDependencies) + $(OutDir)nsfcore.lib;$(OutDir)nsfgui.lib;wxmsw32u_propgrid.lib;wxmsw32u_core.lib;wxbase32u.lib;wxpng.lib;wxzlib.lib;comctl32.lib;rpcrt4.lib;%(AdditionalDependencies) + ..\wxlib\lib\vc_lib\;%(AdditionalLibraryDirectories) Level4 true - _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + __WXMSW__;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true MultiThreadedDebug - ..\include\ + ..\include\;..\wxlib\include\;..\wxlib\lib\vc_x64_lib\mswud\ true Windows true - $(OutDir)nsfcore.lib;$(OutDir)nsfgui.lib;%(AdditionalDependencies) + $(OutDir)nsfcore.lib;$(OutDir)nsfgui.lib;wxmsw32ud_propgrid.lib;wxmsw32ud_core.lib;wxbase32ud.lib;wxpngd.lib;wxzlibd.lib;comctl32.lib;rpcrt4.lib;%(AdditionalDependencies) + ..\wxlib\lib\vc_x64_lib\;%(AdditionalLibraryDirectories) @@ -153,10 +156,10 @@ true true true - NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + __WXMSW__;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true MultiThreaded - ..\include\ + ..\include\;..\wxlib\include\;..\wxlib\lib\vc_x64_lib\mswu\ true @@ -164,7 +167,8 @@ true true true - $(OutDir)nsfcore.lib;$(OutDir)nsfgui.lib;%(AdditionalDependencies) + $(OutDir)nsfcore.lib;$(OutDir)nsfgui.lib;wxmsw32u_propgrid.lib;wxmsw32u_core.lib;wxbase32u.lib;wxpng.lib;wxzlib.lib;comctl32.lib;rpcrt4.lib;%(AdditionalDependencies) + ..\wxlib\lib\vc_x64_lib\;%(AdditionalLibraryDirectories) diff --git a/readme.md b/readme.md index af8a9bc..c7fdb24 100644 --- a/readme.md +++ b/readme.md @@ -8,24 +8,80 @@ This is a work in progress total rewrite of NSFPlay. Goals include: * Winamp plugin. * Rewrite to change the emulation architecture, hopefully more efficient and easier to maintain. -Components: +### Unstable Build + * [Download](https://nightly.link/bbbradsmith/nsfplay/workflows/build/nsfplay3) + +## Components + * `core` - A platform-agnostic NSF player library suitable for integration into other programs. * `gui` - A cross platform GUI library that works with the core, allowing plugins to share the same UI as the stand alone player. * `cmd` - A stand-alone command line player. * `nsfplay` - A stand-alone GUI player. -* `winamp` - A winamp plugin. - -Make targets: -* `make` - builds `cmd`, `gui`, and on windows: `winamp` . -* `make clean` - deletes `intermediate` and `output` directories. -* `make core` - build core library `nsfcore` to `output/make`. -* `make cmd` - build `nsfplac` to `output/make`. -* `make gui` - build gui library `nsfgui` to `output/make`. -* `make nsfplay` - build `nsfplay` to `output/make`. -* `make winamp` - (windows only) build `nsfplay.dll` winamp plugin to `output/make`. -* `make install` - copy `nsfplay`/`nsfplaycmd` to `/usr/local/bin`. -* `make uninstall` - delete install from `/usr/local/bin`. +* `winamp` - A winamp plugin (Windows 32-bit only). +* `wx` - [wxWidgets v3.2.4](https://github.com/wxWidgets/wxWidgets/tree/v3.2.4) cross platform GUI library. + +## Build + +### Visual Studio 2019 + * Initialize the git submodules if it wasn't done when cloning: + * `git submodule init` + * `git submodule update --depth 1` + * `cd wx` + * `git submodule init` + * `git submodule update --depth 1` + * Run `wxlib.bat` to build the wxWidgets libraries. + * Use `nsfplay.sln` to build. + +[Visual Studio 2019](https://visualstudio.microsoft.com/vs/older-downloads/) is the target build tool. Alternatively, [MSYS2](https://www.msys2.org/) can be used to +build with make instead. If you want to use Visual Studio 2022, see the note below about the wxWidgets Library. + +### Make + + * Run `make wxlib` to prepare the wxWidgets libraries. + * Use `make` to build. + +Requirements: + * `make` to run the build. + * `gcc` the chosen compiler. + * `git` (optional) to download the repository and its submodules. + * `cmake` (optional) to build wxWidgets libraries. + * `libgtk-3-dev` (optional) used by wxWidgets on Ubuntu. + +If using MSYS2 you'll need a specific version of `gcc` and `cmake`. You might look at the [build.yml](.github/workflows/build.yml) script to help understand what you need. + +### wxWidgets Library + +You could potentially [download wxWidgets binaries](https://www.wxwidgets.org/downloads/) +and use them instead of having to build them here, +but there is some additional setup required: +* In `nsfplay.sln` open the properties for each project and change `C/C++ > Code Generation > Runtime Library` to `Multi Threaded DLL /MD` or the debug version for all projects. +* Put the `include` folder from the downloaded headers in `wxlib\include`. +* Put the `lib\vc14x_x64_dll` folder from the 64-bit downloaded libraries in `wxlib\lib\vc_x64_lib`. +* Put the `lib\vc14x_dll` folder from the 32-bit downloaded libraries in `wxlib\lib\vc_lib`. + +It's probably easier, however, to just use the `wxlib.bat` file to build it from the submodule source code in `wx`. If you want to try with Visual Studio 2022, you can edit the batch file or set an environment variable: + * `set WXB_GENERATOR="Visual Studio 17 2022"` + * `wxlib.bat` + +Otherwise on other platforms there is probably some wxWidgets library package you can install and use. In theory could could use the `WXL_CONFIG` environment variable to tell the make build how to use it instead. + * `export WXL_CONFIG=/path/to/wx-config` + * `make` + +On Windows (including MSYS2), you don't need to keep the cmake generated directories in wxlib once you've built the libraries. Everything needed will be in `wxlib\include` and `wxlib\lib`, and the other folders can be deleted, if you'd like to recover some space (wxWidgets is unfortunately large). On other platforms, the `wx-config` utility will be contained there, so you should at least keep that and whatever other files it uses to determine its build configuration. + +### Make Targets + +* `make` - builds `cmd`, `gui` +* `make clean` - deletes `intermediate/` and `output/` directories. +* `make core` - build core library `nsfcore` to `output/make/`. +* `make cmd` - build `nsfplac` to `output/make/`. +* `make gui` - build gui library `nsfgui` to `output/make/`. +* `make nsfplay` - build `nsfplay` to `output/make/`. +* `make winamp` - (windows 32-bit only) build `nsfplay.dll` winamp plugin to `output/make/`. +* `make install` - copy `nsfplay`/`nsfplac` to `/usr/local/bin/`. +* `make uninstall` - delete install from `/usr/local/bin/`. * `make install prefix=~/my/directory` - install to custom directory. * `make uninstall prefix=~/my/directory` - uninstall from custom directory. +* `make wxlib` - fetches wxWidgets submodule in `wx/` and builds libraries to `wxlib/`. See `makefile.common` for various potential environment overrides. diff --git a/winamp/makefile b/winamp/makefile index 7a05da3..eabd672 100644 --- a/winamp/makefile +++ b/winamp/makefile @@ -13,16 +13,19 @@ OBJS = $(addprefix $(WINAMP_INTDIR)/,$(SRCS:.cpp=.o)) DEPS = $(addprefix $(WINAMP_INTDIR)/,$(SRCS:.cpp=.d)) CORE = ../$(OUTDIR)/$(CORE_NAME)$(LIB_SUFFIX) GUI = ../$(OUTDIR)/$(GUI_NAME)$(LIB_SUFFIX) +CXXFLAGS_ALL = $(CXXFLAGS) $(CXXFLAGS_EXTRA) $(INC_COMMON) $(WXL_CXXFLAGS) +LDFLAGS_ALL = $(LDFLAGS) $(LDFLAGS_EXTRA) $(LDFLAGS_DLL) +LIBS = $(CORE) $(GUI) $(WXL_LIBS) $(TARGET): $(OBJS) $(CORE) $(GUI) | $(dir $(TARGET)) - $(CXX) -o $(TARGET) $(LDFLAGS) $(LDFLAGS_DLL) $(OBJS) $(CORE) $(GUI) + $(CXX) -o $(TARGET) $(LDFLAGS_ALL) $(OBJS) $(LIBS) $(STRIP_DEBUG) $(WINAMP_INTDIR)/%.d: %.cpp | $(WINAMP_INTDIR)/ - $(CXX) -M -MM -MF $@ -MT $(WINAMP_INTDIR)/$(basename $<).o $(CXXFLAGS) -c $< + $(CXX) -M -MM -MF $@ -MT $(WINAMP_INTDIR)/$(basename $<).o $(CXXFLAGS_ALL) -c $< $(WINAMP_INTDIR)/%.o: %.cpp $(WINAMP_INTDIR)/%.d | $(WINAMP_INTDIR)/ - $(CXX) -o $@ $(CXXFLAGS) -c $< + $(CXX) -o $@ $(CXXFLAGS_ALL) -c $< $(WINAMP_INTDIR)/: $(MKDIR) $@ diff --git a/winamp/winamp.vcxproj b/winamp/winamp.vcxproj index 91d78c3..dfba158 100644 --- a/winamp/winamp.vcxproj +++ b/winamp/winamp.vcxproj @@ -59,19 +59,20 @@ Level4 true - WIN32;_DEBUG;WINAMP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + __WXMSW__;WIN32;_DEBUG;WINAMP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true NotUsing pch.h MultiThreadedDebug - ..\include\ + ..\include\;..\wxlib\include\;..\wxlib\lib\vc_lib\mswud\ true Windows true false - $(OutDir)nsfcore.lib;$(OutDir)nsfgui.lib;%(AdditionalDependencies) + $(OutDir)nsfcore.lib;$(OutDir)nsfgui.lib;wxmsw32ud_propgrid.lib;wxmsw32ud_core.lib;wxbase32ud.lib;wxpngd.lib;wxzlibd.lib;comctl32.lib;rpcrt4.lib;%(AdditionalDependencies) + ..\wxlib\lib\vc_lib\;%(AdditionalLibraryDirectories) $(OutDir)$(TargetFileName).pdb @@ -81,12 +82,12 @@ true true true - WIN32;NDEBUG;WINAMP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + __WXMSW__;WIN32;NDEBUG;WINAMP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true NotUsing pch.h MultiThreaded - ..\include\ + ..\include\;..\wxlib\include\;..\wxlib\lib\vc_lib\mswu\ true @@ -95,7 +96,8 @@ true true false - $(OutDir)nsfcore.lib;$(OutDir)nsfgui.lib;%(AdditionalDependencies) + $(OutDir)nsfcore.lib;$(OutDir)nsfgui.lib;wxmsw32u_propgrid.lib;wxmsw32u_core.lib;wxbase32u.lib;wxpng.lib;wxzlib.lib;comctl32.lib;rpcrt4.lib;%(AdditionalDependencies) + ..\wxlib\lib\vc_lib\;%(AdditionalLibraryDirectories) $(OutDir)$(TargetFileName).pdb diff --git a/wxlib.bat b/wxlib.bat new file mode 100644 index 0000000..70f6203 --- /dev/null +++ b/wxlib.bat @@ -0,0 +1,117 @@ +@REM Define the following environment variables to suppress actions: +@REM WXB_NOPAUSE - don't pause after completion +@REM WXB_NO64 - don't build 64-bit libraries +@REM WXB_NO32 - don't build 32-bit libraries +@REM WXB_NORELEASE - don't build release libraries +@REM WXB_NODEBUG - don't build debug libraries + +@set WXDIR=wx +@set WXOUT=wxlib +@set WXREL=..\wx +@set WXCMAKE64=vc64 +@set WXCMAKE32=vc32 + +@if not defined WXB_GENERATOR set WXB_GENERATOR="Visual Studio 16 2019" + +@set WXCONF=%WXCONF% -G %WXB_GENERATOR% +@set WXCONF=%WXCONF% -DwxBUILD_USE_STATIC_RUNTIME=ON +@set WXCONF=%WXCONF% -DwxBUILD_SHARED=OFF +@set WXCONF=%WXCONF% -DwxUSE_UNICODE=ON +@set WXCONF=%WXCONF% -DwxUSE_AUI=OFF +@set WXCONF=%WXCONF% -DwxUSE_HTML=OFF +@set WXCONF=%WXCONF% -DwxUSE_MEDIACTRL=OFF +@set WXCONF=%WXCONF% -DwxUSE_OPENGL=OFF +@set WXCONF=%WXCONF% -DwxUSE_DEBUGREPORT=OFF +@set WXCONF=%WXCONF% -DwxUSE_RIBBON=OFF +@set WXCONF=%WXCONF% -DwxUSE_RICHTEXT=OFF +@set WXCONF=%WXCONF% -DwxUSE_STC=OFF +@set WXCONF=%WXCONF% -DwxUSE_WEBVIEW=OFF +@set WXCONF=%WXCONF% -DwxUSE_XRC=OFF +@set WXCONF=%WXCONF% -DwxUSE_STL=OFF +@set WXCONF=%WXCONF% -DwxUSE_REGEX=OFF +@set WXCONF=%WXCONF% -DwxUSE_ZLIB=builtin +@set WXCONF=%WXCONF% -DwxUSE_EXPAT=OFF +@set WXCONF=%WXCONF% -DwxUSE_LIBJPEG=OFF +@set WXCONF=%WXCONF% -DwxUSE_LIBPNG=builtin +@set WXCONF=%WXCONF% -DwxUSE_LIBTIFF=OFF +@set WXCONF=%WXCONF% -DwxUSE_NANOSVG=OFF +@set WXCONF=%WXCONF% -DwxUSE_LIBLZMA=OFF +@set WXCONF=%WXCONF% -DwxUSE_WXHTML_HELP=OFF +@echo set WXCONF=%WXCONF% + +REM ensure wx exists +@if not exist "wx\CMakeLists.txt" ( +@echo. +@echo Error: Unable to find wx\CmakeLists.txt +@echo Do you need to set up git submodules? +@echo git submodule init +@echo git submodule update --depth 1 +@echo cd wx +@echo git submodule init +@echo git submodule update --depth 1 +@echo Alternative: manually place wxWidgets source in wx directory. +@echo. +@if not defined WXB_NOPAUSE pause +exit /b 1 +) + +REM locate visual studio vsdevcmd.bat to use cmake +@for /f "usebackq delims=" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath`) do ( +@if exist "%%i\Common7\Tools\vsdevcmd.bat" ( +@call "%%i\Common7\Tools\vsdevcmd.bat" +@goto build +) +) +@echo. +@echo Error: Unable to find Visual Studio installation: %ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe +@echo. +@if not defined WXB_NOPAUSE pause +exit /b 1 + +:build +REM build wxWidgets libraries + +@if defined WXB_NO64 goto :no64 +mkdir %WXOUT%\%WXCMAKE64% +@pushd . +@cd %WXOUT%\%WXCMAKE64% +cmake ..\%WXREL% %WXCONF% -DCMAKE_GENERATOR_PLATFORM=x64 || @goto error +@if defined WXB_NORELEASE goto :norelease64 +cmake --build . --config Release --verbose || @goto error +cmake --install . --prefix .. --config Release || @goto error +:norelease64 +@if defined WXB_NODEBUG goto :nodebug64 +cmake --build . --config Debug --verbose || @goto error +cmake --install . --prefix .. --config Debug || @goto error +:nodebug64 +@popd +:no64 + +@if defined WXB_NO32 goto :no32 +mkdir %WXOUT%\%WXCMAKE32% +@pushd . +@cd %WXOUT%\%WXCMAKE32% +cmake ..\%WXREL% %WXCONF% -DCMAKE_GENERATOR_PLATFORM=Win32 || @goto error +@if defined WXB_NORELEASE goto :norelease32 +cmake --build . --config Release --verbose || @goto error +cmake --install . --prefix .. --config Release || @goto error +:norelease32 +@if defined WXB_NODEBUG goto :nodebug32 +cmake --build . --config Debug --verbose || @goto error +cmake --install . --prefix .. --config Debug || @goto error +:nodebug32 +@popd +:no32 + +@echo. +@echo Success. +@echo. +@if not defined WXB_NOPAUSE pause +exit /b 0 + +:error +@echo. +@echo Unable to build wxWidgets libraries. See error above. +@echo. +@if not defined WXB_NOPAUSE pause +exit /b 1