1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-05-12 12:00:13 +00:00

Generate .license.txt file with license information

This gives QB64-PE the ability to automatically generate a text file
comprising all of the licenses that apply to your QB64 program. This
file can then be distributed with your program to meet the requirements
of those licenses, and also examined to understand what licenses apply
to your program.

The generation is controlled via a configuration flag, settable either
via the `Run` dialog, or via a new `-f` setting on the comamnd line.

Fixes: #145
This commit is contained in:
Matthew Kilgore 2022-09-18 02:01:30 -04:00
parent 18f746018b
commit 908585aa2e
23 changed files with 137 additions and 9 deletions

View file

@ -123,6 +123,11 @@ ifndef EXE
$(error Please provide executable name as 'EXE=executable')
endif
GENERATE_LICENSE ?= n
LICENSE ?= $(EXE).license.txt
LICENSE_IN_USE := qb64
all: $(EXE)
CLEAN_LIST :=
@ -204,6 +209,8 @@ endif
ifneq ($(filter y,$(DEP_SCREENIMAGE) $(DEP_IMAGE_CODEC)),)
CXXFLAGS += -DDEPENDENCY_IMAGE_CODEC
QBLIB_NAME := $(addsuffix 1,$(QBLIB_NAME))
LICENSE_IN_USE += dr_pcx stb_image
else
QBLIB_NAME := $(addsuffix 0,$(QBLIB_NAME))
endif
@ -257,6 +264,8 @@ ifneq ($(filter y,$(DEP_FONT)),)
EXE_LIBS += $(QB_FONT_LIB)
CXXFLAGS += -DDEPENDENCY_LOADFONT
QBLIB_NAME := $(addsuffix 1,$(QBLIB_NAME))
LICENSE_IN_USE += freetype_ftl
else
QBLIB_NAME := $(addsuffix 0,$(QBLIB_NAME))
endif
@ -274,6 +283,12 @@ ifneq ($(filter y,$(DEP_AUDIO_MINIAUDIO)),)
CXXFLAGS += -DDEPENDENCY_AUDIO_MINIAUDIO
QBLIB_NAME := $(addsuffix 1,$(QBLIB_NAME))
LICENSE_IN_USE += miniaudio libxmp-lite radv2 stbvorbis
ifdef DEP_AUDIO_DECODE_MIDI
LICENSE_IN_USE += tinysoundfont tinymidiloader
endif
else
QBLIB_NAME := $(addsuffix 0,$(QBLIB_NAME))
endif
@ -282,6 +297,8 @@ ifneq ($(filter y,$(DEP_AUDIO_CONVERSION) $(DEP_AUDIO_DECODE)),)
EXE_LIBS += $(QB_AUDIO_CONVERSION_LIB)
CXXFLAGS += -DDEPENDENCY_AUDIO_CONVERSION
QBLIB_NAME := $(addsuffix 1,$(QBLIB_NAME))
LICENSE_IN_USE += opus
else
QBLIB_NAME := $(addsuffix 0,$(QBLIB_NAME))
endif
@ -290,6 +307,8 @@ ifneq ($(filter y,$(DEP_AUDIO_DECODE)),)
EXE_LIBS += $(QB_AUDIO_DECODE_MP3_LIB) $(QB_AUDIO_DECODE_OGG_LIB)
CXXFLAGS += -DDEPENDENCY_AUDIO_DECODE
QBLIB_NAME := $(addsuffix 1,$(QBLIB_NAME))
LICENSE_IN_USE += mpg123 stbvorbis
else
QBLIB_NAME := $(addsuffix 0,$(QBLIB_NAME))
endif
@ -301,6 +320,8 @@ ifneq ($(filter y,$(DEP_AUDIO_OUT) $(DEP_AUDIO_CONVERSION) $(DEP_AUDIO_DECODE)),
CXXLIBS += -framework AudioUnit -framework AudioToolbox
endif
QBLIB_NAME := $(addsuffix 1,$(QBLIB_NAME))
LICENSE_IN_USE += openal
else
QBLIB_NAME := $(addsuffix 0,$(QBLIB_NAME))
endif
@ -313,15 +334,21 @@ ifneq ($(filter y,$(DEP_ZLIB)),)
CXXLIBS += "-l:libz.a"
endif
QBLIB_NAME := $(addsuffix 1,$(QBLIB_NAME))
LICENSE_IN_USE += zlib
else
QBLIB_NAME := $(addsuffix 0,$(QBLIB_NAME))
endif
ifneq ($(OS),osx)
EXE_LIBS += $(QB_CORE_LIB)
LICENSE_IN_USE += freeglut
endif
ifeq ($(OS),win)
LICENSE_IN_USE += mingw-base-runtime libstdc++
ifneq ($(filter y,$(DEP_CONSOLE_ONLY) $(DEP_CONSOLE)),)
CXXLIBS += -mconsole
endif
@ -329,6 +356,8 @@ ifeq ($(OS),win)
ifneq ($(filter y,$(DEP_CONSOLE_ONLY)),)
CXXFLAGS := $(filter-out -DFREEGLUT_STATIC,$(CXXFLAGS))
EXE_LIBS := $(filter-out $(QB_CORE_LIB),$(EXE_LIBS))
LICENSE_IN_USE := $(filter-out freeglut,$(LICENSE_IN_USE))
else
CXXLIBS += -mwindows -lopengl32 -lglu32 -lwinmm
endif
@ -358,6 +387,7 @@ ifneq ($(filter y,$(DEP_DATA)),)
EXE_OBJS += $(PATH_INTERNAL_TEMP)/data.o
endif
QBLIB := $(PATH_INTERNAL_C)/$(QBLIB_NAME).o
ifneq ($(OS),osx)
@ -390,7 +420,12 @@ CLEAN_LIST := $(filter-out $(PATH_INTERNAL_TEMP)/temp.bin,$(CLEAN_LIST))
clean: $(CLEAN_DEP_LIST)
$(RM) $(call FIXPATH,$(CLEAN_LIST))
$(EXE): $(EXE_OBJS) $(EXE_LIBS)
ifeq ($(GENERATE_LICENSE),y)
LICENSE_FILES := $(patsubst %,licenses/license_%.txt,$(LICENSE_IN_USE))
LICENSE_DEP := $(LICENSE)
endif
$(EXE): $(EXE_OBJS) $(EXE_LIBS) $(LICENSE_DEP)
$(CXX) $(CXXFLAGS) $(EXE_OBJS) -o "$@" $(EXE_LIBS) $(CXXLIBS)
ifneq ($(filter-out osx,$(OS)),)
ifneq ($(STRIP_SYMBOLS),n)
@ -399,5 +434,14 @@ ifneq ($(STRIP_SYMBOLS),n)
endif
endif
$(LICENSE): $(LICENSE_FILES)
ifeq ($(GENERATE_LICENSE),y)
ifeq ($(OS),win)
type $(call FIXPATH,$^) > "$@"
else
cat $^ > "$@"
endif
endif
-include ./tests/build.mk

View file

@ -111,6 +111,8 @@ These flags control some basic settings for how the `Makefile` can compile the p
| `CXXLIBS_EXTRA` | None | Collection of linker flags | No | These flags are provided to the compiler (`g++` or `clang++`) when linking the final executable. Typically includes the `-l` library flags |
| `CFLAGS_EXTRA` | None | Collection of C compiler flags | No | These flags are provided to the compiler when building C files |
| `STRIP_SYMBOLS` | None | `n` | No | Symbols are stripped by default, if this is `n` then symbols will not be stripped from the executable |
| `GENERATE_LICENSE` | None | `y` | No | Generates a `.license.txt` file next to your executable, which contains all the licenses that apply to the executable |
| `LICENSE` | `$(EXE).license.txt`| License file name | No | Specifies an alternative filename for the license file |
These flags controls whether certain dependencies are compiled in or not. All of them are blank by default and should be set to `y` to use them. Note that the program being built may not compile if you supply the wrong dependency settings - may of them supply functions that will not be defined if the dependency is required, and some of them (Ex. `DEP_GL`) have requirements the program being compiled must meet.

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
License of PCX Image Loader:
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or

View file

@ -1,3 +1,5 @@
--------------------------------------------------------------------------------
License of FreeGLUT:
Freeglut Copyright
------------------

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
License of FreeType:
The FreeType Project LICENSE
----------------------------

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
License of libstdc++ from MinGW:
GCC RUNTIME LIBRARY EXCEPTION
Version 3.1, 31 March 2009

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
License of libxmp-lite:
__ _ __ ___ __
/ / (_) / __ __ __ _ ___ ____/ (_) /____
/ /__/ / _ \\ \ // ' \/ _ \/___/ / / __/ -_)

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
License of MinGW-w64 base runtime:
MinGW-w64 runtime licensing
***************************

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
License of Miniaudio:
This software is available as a choice of the following licenses. Choose
whichever you prefer.
@ -44,4 +47,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
License of mpg123:
=======================
1. The LGPL version 2.1
=======================

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
License of OpenAL:
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991

View file

@ -1,3 +1,5 @@
--------------------------------------------------------------------------------
License of Opus Tools:
Opus-tools, with the exception of opusinfo.[ch] is available under
the following two clause BSD-style license:

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
License of QB64-PE runtime:
Copyright 2007-2022 Galleon & The QB64 Team
Copyright 2022-2023 QB64 Phoenix Edition Team

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
Licenseof RADv2:
From: Willy Reeve <shayde0@gmail.com>
Sent: Sunday, 7 August, 2022 01:23 PM
To: Samuel Gomes <v_2samg@hotmail.com>

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
License of stb_image:
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
License of stb_vorbis:
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
License of TinyMidiLoader:
Copyright (C) 2017, 2018, 2020 Bernhard Schelling
This software is provided 'as-is', without any express or implied

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
License of TinySoundFont:
Copyright (C) 2017-2018 Bernhard Schelling (Based on SFZero, Copyright (C) 2012 Steve Folta, https://github.com/stevefolta/SFZero)
Permission is hereby granted, free of charge, to any person obtaining a copy of

View file

@ -1,3 +1,6 @@
--------------------------------------------------------------------------------
License of zlib:
* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.2.11, January 15th, 2017
@ -22,4 +25,4 @@
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
*/
*/

View file

@ -26,6 +26,7 @@ DIM SHARED ExtraCppFlags AS STRING, ExtraLinkerFlags AS STRING
DIM SHARED StripDebugSymbols AS _UNSIGNED LONG
DIM SHARED OptimizeCppProgram AS _UNSIGNED LONG
DIM SHARED UseMiniaudioBackend AS _UNSIGNED LONG
DIM SHARED GenerateLicenseFile AS _UNSIGNED LONG
ConfigFile$ = "internal/config.ini"
iniFolderIndex$ = STR$(tempfolderindex)
@ -537,6 +538,7 @@ ExtraCppFlags = ReadWriteStringSettingValue$(compilerSettingsSection$, "ExtraCpp
ExtraLinkerFlags = ReadWriteStringSettingValue$(compilerSettingsSection$, "ExtraLinkerFlags", "")
UseMiniaudioBackend = ReadWriteBooleanSettingValue%(compilerSettingsSection$, "UseMiniaudioBackend", -1)
GenerateLicenseFile = ReadWriteBooleanSettingValue%(compilerSettingsSection$, "GenerateLicenseFile", 0)
'End of initial settings ------------------------------------------------------

View file

@ -222,6 +222,7 @@ DIM SHARED ViewMenuID AS INTEGER, ViewMenuShowLineNumbersSubMenuID AS INTEGER
DIM SHARED ViewMenuShowSeparatorID AS INTEGER, ViewMenuShowBGID AS INTEGER
DIM SHARED ViewMenuCompilerWarnings AS INTEGER
DIM SHARED RunMenuID AS INTEGER, RunMenuSaveExeWithSource AS INTEGER, brackethighlight AS INTEGER
DIM SHARED GenerateLicenseEnableMenu AS INTEGER
DIM SHARED DebugMenuID AS INTEGER, DebugMenuCallStack AS INTEGER, DebugMenuWatchListToConsole AS INTEGER
DIM SHARED DebugMenuAutoAddCommand AS INTEGER
DIM SHARED multihighlight AS INTEGER, keywordHighlight AS INTEGER

View file

@ -343,6 +343,12 @@ FUNCTION ide2 (ignore)
IF SaveExeWithSource THEN
menu$(RunMenuID, RunMenuSaveExeWithSource) = CHR$(7) + menu$(RunMenuID, RunMenuSaveExeWithSource)
END IF
GenerateLicenseEnableMenu = i
menu$(m, i) = "#Generate License For EXE": i = i + 1
menuDesc$(m, i - 1) = "The license file is placed next to the executable"
IF GenerateLicenseFile THEN
menu$(RunMenuID, GenerateLicenseEnableMenu) = CHR$(7) + menu$(RunMenuID, GenerateLicenseEnableMenu)
END IF
menu$(m, i) = "-": i = i + 1
IF os$ = "LNX" THEN
@ -5053,6 +5059,21 @@ FUNCTION ide2 (ignore)
GOTO ideloop
END IF
IF MID$(menu$(m, s), 1) = "#Generate License For EXE" OR MID$(menu$(m, s), 2) = "#Generate License For EXE" THEN
PCOPY 2, 0
GenerateLicenseFile = NOT GenerateLicenseFile
WriteConfigSetting compilerSettingsSection$, "GenerateLicenseFile", BoolToTFString$(GenerateLicenseFile)
IF GenerateLicenseFile THEN
menu$(RunMenuID, GenerateLicenseEnableMenu) = CHR$(7) + "#Generate License For EXE"
ELSE
menu$(RunMenuID, GenerateLicenseEnableMenu) = "#Generate License For EXE"
END IF
PCOPY 3, 0: SCREEN , , 3, 0
GOTO ideloop
END IF
IF RIGHT$(menu$(m, s), 29) = "#Output Watch List to Console" THEN
PCOPY 2, 0
WatchListToConsole = NOT WatchListToConsole

View file

@ -12563,6 +12563,11 @@ IF NOT StripDebugSymbols THEN
makeline$ = makeline$ + " STRIP_SYMBOLS=n"
END IF
' We avoid generating the license file if the user picked the "No Exe" option
IF GenerateLicenseFile AND NOT NoExeSaved THEN
makeline$ = makeline$ + " GENERATE_LICENSE=y"
END IF
IF os$ = "WIN" THEN
makeline$ = makeline$ + " OS=win"
@ -13269,6 +13274,9 @@ FUNCTION ParseCMDLineArgs$ ()
IF NOT ParseLongSetting&(token$, MaxParallelProcesses) THEN PrintTemporarySettingsHelpAndExit InvalidSettingError$(token$)
IF MaxParallelProcesses = 0 THEN PrintTemporarySettingsHelpAndExit "MaxCompilerProcesses must be more than zero"
CASE ":generatelicensefile"
IF NOT ParseBooleanSetting&(token$, GenerateLicenseFile) THEN PrintTemporarySettingsHelpAndExit InvalidSettingError$(token$)
CASE ELSE
PrintTemporarySettingsHelpAndExit ""
END SELECT
@ -13302,12 +13310,13 @@ SUB PrintTemporarySettingsHelpAndExit(errstr$)
PRINT "Note: Defaults can be changed by IDE settings"
PRINT
PRINT "Valid settings:"
PRINT " -f:UseMiniAudio=[true|false] (Use Miniaudio Audio backend, default true)"
PRINT " -f:OptimizeCppProgram=[true|false] (Use C++ Optimization flag, default false)"
PRINT " -f:StripDebugSymbols=[true|false] (Stirp C++ debug symbols, default true)"
PRINT " -f:ExtraCppFlags=[string] (Extra flags to pass to the C++ compiler)"
PRINT " -f:ExtraLinkerFlags=[string] (Extra flags to pass at link time)"
PRINT " -f:MaxCompilerProcesses=[integer] (Max C++ compiler processes to start in parallel)"
PRINT " -f:UseMiniAudio=[true|false] (Use Miniaudio Audio backend, default true)"
PRINT " -f:OptimizeCppProgram=[true|false] (Use C++ Optimization flag, default false)"
PRINT " -f:StripDebugSymbols=[true|false] (Stirp C++ debug symbols, default true)"
PRINT " -f:ExtraCppFlags=[string] (Extra flags to pass to the C++ compiler)"
PRINT " -f:ExtraLinkerFlags=[string] (Extra flags to pass at link time)"
PRINT " -f:MaxCompilerProcesses=[integer] (Max C++ compiler processes to start in parallel)"
PRINT " -f:GenerateLicenseFile=[true|false] (Produce a license.txt file for the program)"
SYSTEM
END SUB