From cb8331f21355da083c60cec0a9b3b98c2ab25213 Mon Sep 17 00:00:00 2001 From: swiftlyfalling Date: Mon, 30 May 2016 21:16:36 -0400 Subject: [PATCH] Renamed customizable files to -USER, added .example files, preserve user customizations. Added .example files. Added build phase script to copy .example files if user configuration files are not already present. --- GRDB.xcodeproj/project.pbxproj | 57 ++++++++++++++++++- SQLiteCustom/GRDB.xcconfig | 3 +- .../GRDBCustomSQLite-Testing.xcconfig | 3 +- SQLiteCustom/GRDBCustomSQLite-USER.h.example | 9 +++ ...cconfig => GRDBCustomSQLite-USER.xcconfig} | 2 +- .../GRDBCustomSQLite-USER.xcconfig.example | 16 ++++++ SQLiteCustom/GRDBCustomSQLite.h | 4 +- 7 files changed, 86 insertions(+), 8 deletions(-) create mode 100755 SQLiteCustom/GRDBCustomSQLite-USER.h.example rename SQLiteCustom/{GRDBCustomSQLite-Custom.xcconfig => GRDBCustomSQLite-USER.xcconfig} (79%) create mode 100755 SQLiteCustom/GRDBCustomSQLite-USER.xcconfig.example diff --git a/GRDB.xcodeproj/project.pbxproj b/GRDB.xcodeproj/project.pbxproj index 4149bd3f4..cfe5ae235 100755 --- a/GRDB.xcodeproj/project.pbxproj +++ b/GRDB.xcodeproj/project.pbxproj @@ -717,6 +717,8 @@ DC2393C81ABE35F8003FF113 /* GRDB-Bridging.h in Headers */ = {isa = PBXBuildFile; fileRef = DC2393C61ABE35F8003FF113 /* GRDB-Bridging.h */; settings = {ATTRIBUTES = (Public, ); }; }; DC3773F919C8CBB3004FCF85 /* GRDB.h in Headers */ = {isa = PBXBuildFile; fileRef = DC3773F819C8CBB3004FCF85 /* GRDB.h */; settings = {ATTRIBUTES = (Public, ); }; }; DC70AC991AC2331000371524 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = DC37744219C8DC91004FCF85 /* libsqlite3.dylib */; }; + EED476F21CFD17270026A4EC /* GRDBCustomSQLite-USER.h in Headers */ = {isa = PBXBuildFile; fileRef = EED476F11CFD16FF0026A4EC /* GRDBCustomSQLite-USER.h */; settings = {ATTRIBUTES = (Public, ); }; }; + EED476F31CFD172C0026A4EC /* GRDBCustomSQLite-USER.h in Headers */ = {isa = PBXBuildFile; fileRef = EED476F11CFD16FF0026A4EC /* GRDBCustomSQLite-USER.h */; settings = {ATTRIBUTES = (Public, ); }; }; F3BA800A1CFB286A003DC1BA /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238701B9C75030082EB20 /* Configuration.swift */; }; F3BA800B1CFB286D003DC1BA /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238711B9C75030082EB20 /* Database.swift */; }; F3BA800C1CFB286F003DC1BA /* DatabaseError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238731B9C75030082EB20 /* DatabaseError.swift */; }; @@ -1340,6 +1342,7 @@ DC37740419C8CBB3004FCF85 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; DC37744219C8DC91004FCF85 /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; DC37744719C8F50B004FCF85 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; + EED476F11CFD16FF0026A4EC /* GRDBCustomSQLite-USER.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "GRDBCustomSQLite-USER.h"; path = "SQLiteCustom/GRDBCustomSQLite-USER.h"; sourceTree = ""; }; F3BA7FEE1CFB23B7003DC1BA /* GRDB.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = GRDB.xcconfig; path = SQLiteCustom/GRDB.xcconfig; sourceTree = ""; }; F3BA7FEF1CFB23BF003DC1BA /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; name = module.modulemap; path = SQLiteCustom/module.modulemap; sourceTree = ""; }; F3BA7FF01CFB23C9003DC1BA /* sqlite3.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = sqlite3.h; path = SQLiteCustom/src/sqlite3.h; sourceTree = ""; }; @@ -1350,7 +1353,7 @@ F3BA80411CFB2AD7003DC1BA /* GRDBCustomSQLiteiOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBCustomSQLiteiOSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; F3BA805A1CFB2BB2003DC1BA /* GRDBCustomSQLite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GRDBCustomSQLite.framework; sourceTree = BUILT_PRODUCTS_DIR; }; F3BA809B1CFB2F6F003DC1BA /* GRDBCustomSQLiteOSXTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBCustomSQLiteOSXTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - F3BA813A1CFB3402003DC1BA /* GRDBCustomSQLite-Custom.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "GRDBCustomSQLite-Custom.xcconfig"; path = "SQLiteCustom/GRDBCustomSQLite-Custom.xcconfig"; sourceTree = ""; }; + F3BA813A1CFB3402003DC1BA /* GRDBCustomSQLite-USER.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "GRDBCustomSQLite-USER.xcconfig"; path = "SQLiteCustom/GRDBCustomSQLite-USER.xcconfig"; sourceTree = ""; }; F3BA813B1CFB3770003DC1BA /* GRDBCustomSQLite-Testing.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "GRDBCustomSQLite-Testing.xcconfig"; path = "SQLiteCustom/GRDBCustomSQLite-Testing.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -2108,10 +2111,19 @@ path = ../Support; sourceTree = ""; }; + EED476F41CFD174D0026A4EC /* Customize */ = { + isa = PBXGroup; + children = ( + F3BA813A1CFB3402003DC1BA /* GRDBCustomSQLite-USER.xcconfig */, + EED476F11CFD16FF0026A4EC /* GRDBCustomSQLite-USER.h */, + ); + name = Customize; + sourceTree = ""; + }; F3BA7FED1CFB21F8003DC1BA /* GRDBCustomSQLite */ = { isa = PBXGroup; children = ( - F3BA813A1CFB3402003DC1BA /* GRDBCustomSQLite-Custom.xcconfig */, + EED476F41CFD174D0026A4EC /* Customize */, F3BA7FEE1CFB23B7003DC1BA /* GRDB.xcconfig */, F3BA813B1CFB3770003DC1BA /* GRDBCustomSQLite-Testing.xcconfig */, F3BA7FEF1CFB23BF003DC1BA /* module.modulemap */, @@ -2179,6 +2191,7 @@ F3BA80381CFB2932003DC1BA /* GRDBCustomSQLite.h in Headers */, F3BA80391CFB2936003DC1BA /* GRDBCustomSQLite-Bridging.h in Headers */, F3BA803A1CFB293A003DC1BA /* sqlite3.h in Headers */, + EED476F31CFD172C0026A4EC /* GRDBCustomSQLite-USER.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2189,6 +2202,7 @@ F3BA80931CFB2F13003DC1BA /* GRDBCustomSQLite.h in Headers */, F3BA80941CFB2F15003DC1BA /* GRDBCustomSQLite-Bridging.h in Headers */, F3BA80951CFB2F18003DC1BA /* sqlite3.h in Headers */, + EED476F21CFD17270026A4EC /* GRDBCustomSQLite-USER.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2419,6 +2433,7 @@ isa = PBXNativeTarget; buildConfigurationList = F3BA80031CFB25E4003DC1BA /* Build configuration list for PBXNativeTarget "GRDBCustomSQLiteiOS" */; buildPhases = ( + EED476F01CFD0B290026A4EC /* Copy .example configuration files (if no USER customizations exist) */, F3BA7FF91CFB25E4003DC1BA /* Sources */, F3BA7FFA1CFB25E4003DC1BA /* Frameworks */, F3BA7FFB1CFB25E4003DC1BA /* Headers */, @@ -2455,6 +2470,7 @@ isa = PBXNativeTarget; buildConfigurationList = F3BA805F1CFB2BB2003DC1BA /* Build configuration list for PBXNativeTarget "GRDBCustomSQLiteOSX" */; buildPhases = ( + EED476F51CFD1A610026A4EC /* Copy .example configuration files (if no USER customizations exist) */, F3BA80551CFB2BB2003DC1BA /* Sources */, F3BA80561CFB2BB2003DC1BA /* Frameworks */, F3BA80571CFB2BB2003DC1BA /* Headers */, @@ -2762,6 +2778,43 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + EED476F01CFD0B290026A4EC /* Copy .example configuration files (if no USER customizations exist) */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(SRCROOT)/SQLiteCustom/GRDBCustomSQLite-USER.xcconfig.example", + "$(SRCROOT)/SQLiteCustom/GRDBCustomSQLite-USER.h.example", + ); + name = "Copy .example configuration files (if no USER customizations exist)"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "for ((i=0; i < SCRIPT_INPUT_FILE_COUNT ; i++))\ndo\n INFILE=SCRIPT_INPUT_FILE_$i\n FILE=${!INFILE};\n OUTPUTFILE=${FILE%.example}\n echo \"${INFILE}=${FILE}\"\n if [ -f \"$FILE\" ]\n then\n if [ ! -f \"$OUTPUTFILE\" ];\n then\n echo \"Expected USER configuration file doesn't exist\"\n echo \"Copying .example file\"\n cp $FILE $OUTPUTFILE\n else\n echo \"USER Configuration file already exists: ${OUTPUTFILE}\"\n echo \"Skipping .example copy.\"\n fi\n else\n echo \"Missing input .example file: ${FILE}\"\n exit 1\n fi\ndone\n"; + showEnvVarsInLog = 0; + }; + EED476F51CFD1A610026A4EC /* Copy .example configuration files (if no USER customizations exist) */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(SRCROOT)/SQLiteCustom/GRDBCustomSQLite-USER.xcconfig.example", + "$(SRCROOT)/SQLiteCustom/GRDBCustomSQLite-USER.h.example", + ); + name = "Copy .example configuration files (if no USER customizations exist)"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "for ((i=0; i < SCRIPT_INPUT_FILE_COUNT ; i++))\ndo\n INFILE=SCRIPT_INPUT_FILE_$i\n FILE=${!INFILE};\n OUTPUTFILE=${FILE%.example}\n echo \"${INFILE}=${FILE}\"\n if [ -f \"$FILE\" ]\n then\n if [ ! -f \"$OUTPUTFILE\" ];\n then\n echo \"Expected USER configuration file doesn't exist\"\n echo \"Copying .example file\"\n cp $FILE $OUTPUTFILE\n else\n echo \"USER Configuration file already exists: ${OUTPUTFILE}\"\n echo \"Skipping .example copy.\"\n fi\n else\n echo \"Missing input .example file: ${FILE}\"\n exit 1\n fi\ndone\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 560C97D41C0E22D300BF8471 /* Sources */ = { isa = PBXSourcesBuildPhase; diff --git a/SQLiteCustom/GRDB.xcconfig b/SQLiteCustom/GRDB.xcconfig index 4f3dcc6a3..8db96cd11 100755 --- a/SQLiteCustom/GRDB.xcconfig +++ b/SQLiteCustom/GRDB.xcconfig @@ -1,4 +1,5 @@ -#include "GRDBCustomSQLite-Custom.xcconfig" +// Build once to generate this file: +#include "GRDBCustomSQLite-USER.xcconfig" #include "../SQLiteCustom/src/SQLiteLib-Custom.xcconfig" INFOPLIST_FILE = Support/Info.plist diff --git a/SQLiteCustom/GRDBCustomSQLite-Testing.xcconfig b/SQLiteCustom/GRDBCustomSQLite-Testing.xcconfig index 6c90d7c4c..6dd18bd85 100755 --- a/SQLiteCustom/GRDBCustomSQLite-Testing.xcconfig +++ b/SQLiteCustom/GRDBCustomSQLite-Testing.xcconfig @@ -1,7 +1,8 @@ // DO NOT MODIFY. // This config file is used to expose other settings to the test bundle. -#include "GRDBCustomSQLite-Custom.xcconfig" +// Build once to generate this file: +#include "GRDBCustomSQLite-USER.xcconfig" #include "../SQLiteCustom/src/SQLiteLib-Custom.xcconfig" OTHER_CFLAGS = -DUSING_BUILTIN_SQLITE -DUSING_CUSTOMSQLITE $(CUSTOM_SQLLIBRARY_CFLAGS) // Do not modify. diff --git a/SQLiteCustom/GRDBCustomSQLite-USER.h.example b/SQLiteCustom/GRDBCustomSQLite-USER.h.example new file mode 100755 index 000000000..b15b56745 --- /dev/null +++ b/SQLiteCustom/GRDBCustomSQLite-USER.h.example @@ -0,0 +1,9 @@ +// DO NOT INCLUDE THIS FILE DIRECTLY +// INSTEAD, INCLUDE "GRDBCustomSQLite.h" + +// +// INSERT ANY ADDITIONAL SQLITE DEFINES HERE +// +#define SQLITE_ENABLE_PREUPDATE_HOOK +// ----------------------------------------- + diff --git a/SQLiteCustom/GRDBCustomSQLite-Custom.xcconfig b/SQLiteCustom/GRDBCustomSQLite-USER.xcconfig similarity index 79% rename from SQLiteCustom/GRDBCustomSQLite-Custom.xcconfig rename to SQLiteCustom/GRDBCustomSQLite-USER.xcconfig index cb69256e2..c550f72cb 100755 --- a/SQLiteCustom/GRDBCustomSQLite-Custom.xcconfig +++ b/SQLiteCustom/GRDBCustomSQLite-USER.xcconfig @@ -2,7 +2,7 @@ // To compile SQLite with additional compilation options: // 1.) Add them to the "SQLiteLib-Custom.xcconfig" in the SQLiteLib.xcodeproj // 2.) Add them to the CUSTOM_OTHER_SWIFT_FLAGS line below. -// 3.) Optionally add them to "GRDBCustomSQLite.h" to expose the appropriate SQLite APIs to framework consumers. +// 3.) Optionally add them to "GRDBCustomSQLite-Custom.h" to expose the appropriate SQLite APIs to framework consumers. // // How to Convert OTHER_CFLAGS to OTHER_SWIFT_FLAGS: // Add a space after the "-D" diff --git a/SQLiteCustom/GRDBCustomSQLite-USER.xcconfig.example b/SQLiteCustom/GRDBCustomSQLite-USER.xcconfig.example new file mode 100755 index 000000000..ce0259e77 --- /dev/null +++ b/SQLiteCustom/GRDBCustomSQLite-USER.xcconfig.example @@ -0,0 +1,16 @@ + +// To compile SQLite with additional compilation options: +// 1.) Add them to the "SQLiteLib-Custom.xcconfig" in the SQLiteLib.xcodeproj +// 2.) Add them to the CUSTOM_OTHER_SWIFT_FLAGS line below. +// 3.) Optionally add them to "GRDBCustomSQLite-USER.h" to expose the appropriate SQLite APIs to framework consumers. +// +// How to Convert OTHER_CFLAGS to OTHER_SWIFT_FLAGS: +// Add a space after the "-D" +// +// Example: +// OTHER_CFLAGS = -DSQLITE_ENABLE_PREUPDATE_HOOK +// becomes +// CUSTOM_OTHER_SWIFT_FLAGS = -D SQLITE_ENABLE_PREUPDATE_HOOK + +CUSTOM_OTHER_SWIFT_FLAGS = -D SQLITE_ENABLE_PREUPDATE_HOOK + diff --git a/SQLiteCustom/GRDBCustomSQLite.h b/SQLiteCustom/GRDBCustomSQLite.h index 33d63d808..19b7945ad 100755 --- a/SQLiteCustom/GRDBCustomSQLite.h +++ b/SQLiteCustom/GRDBCustomSQLite.h @@ -6,8 +6,6 @@ FOUNDATION_EXPORT double GRDB_VersionNumber; //! Project version string for GRDB. FOUNDATION_EXPORT const unsigned char GRDB_VersionString[]; -// INSERT ANY ADDITIONAL SQLITE DEFINES HERE -#define SQLITE_ENABLE_PREUPDATE_HOOK -// ----------------------------------------- +#import #import #import