Skip to content

Commit 04e3b49

Browse files
Revamp build process to use SQLiteLib-USER.xcconfig
* Rename SQLiteLib-Custom.xcconfig to SQLiteLib-USER.xcconfig * Add SQLiteLib-USER.xcconfig.example file * Remove USER.xcconfig from repo * Add SQLiteLib-USER.xcconfig to .gitignore * Update README * Add Process USER file script as Scheme Pre-Action This enables support for parent-directory override of the USER configuration file. * Remove the amalgamation build scheme from shared. * Disable "Autocreate schemes" in the project
1 parent b7a0419 commit 04e3b49

File tree

8 files changed

+57
-91
lines changed

8 files changed

+57
-91
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,6 @@ xcuserdata/
123123

124124
### Files generated by project build ###
125125
/sqlite3.h
126+
127+
### USER configuration files ###
128+
/SQLiteLib-USER.xcconfig

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ If you need a specific version of SQLite, or specific SQLite compilation options
88

99

1010

11-
**May 29, 2016: SQLiteLib updated for SQLite 3.13.0** ([changelog](CHANGELOG.md)).
11+
**May 31, 2016: SQLiteLib build process tweaks** ([changelog](CHANGELOG.md)).
1212

1313
**Requirements**: iOS 8.0+ / OSX 10.9+, Xcode 7.3+
1414

@@ -49,7 +49,7 @@ By default, SQLiteLib builds SQLite with options that match the built-in system
4949
5050
To specify additional options:
5151

52-
1. Open `SQLiteLib-Custom.xcconfig`
52+
1. Open `SQLiteLib-USER.xcconfig`
5353
2. Modify `CUSTOM_SQLLIBRARY_CFLAGS` to specify the additional options.
5454

5555
For example, to specify SQLITE\_ENABLE\_PREUPDATE\_HOOK, you would modify it like this:
@@ -60,6 +60,14 @@ CUSTOM_SQLLIBRARY_CFLAGS = -DSQLITE_ENABLE_PREUPDATE_HOOK
6060
That's it.
6161
There is no need to modify any other files.
6262

63+
> **NOTE:** If `SQLiteLib-USER.xcconfig` doesn't exist, copy the `SQLiteLib-USER.xcconfig.example` file and rename it, or build once (which will automatically do this for you). ([Reference](#notes))
64+
65+
##### Special Note:
66+
67+
SQLiteLib's build process searches multiple locations for the `SQLiteLib-USER.xcconfig` file.
68+
69+
You can place the file in the **parent directory** (i.e. the directory that contains SQLiteLib.xcodeproj), and SQLiteLib will **always** use that version of the file.
70+
6371

6472
#### Compiling a Specific Version of SQLite:
6573

@@ -167,4 +175,7 @@ Xcode (verified in Version 7.3.1 (7D1014)) will always show "sqlite3.c" as red/m
167175

168176
This is a UI issue in Xcode - the path is properly set in the project.pbxproj file to be "Relative to Build Products", and the build should succeed.
169177

178+
##### There's no SQLiteLib-USER.xcconfig:
179+
180+
SQLiteLib will automatically generate this from the base template `SQLiteLib-USER.xcconfig.example` on first build, or you may copy and rename it yourself.
170181

SQLiteLib-Custom.xcconfig renamed to SQLiteLib-USER.xcconfig.example

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
// Custom additions to the SQLite compilation options
33
// These are merged with the default options (for OSX / iOS)
44
//
5-
// As an example, SQLITE_ENABLE_PREUPDATE_HOOK is set below.
6-
// (On SQLite 3.13.0+, this enables pre-update hook functionality.)
5+
// Example:
6+
// To build with SQLITE_ENABLE_PREUPDATE_HOOK set,
7+
// modify the CUSTOM_SQLLIBRARY_CFLAGS line below to:
8+
//
9+
// CUSTOM_SQLLIBRARY_CFLAGS = -DSQLITE_ENABLE_PREUPDATE_HOOK
710
//
811
// For more information on the options, see: https://www.sqlite.org/compile.html
912

1013
// Added to OTHER_CFLAGS in all cases
11-
CUSTOM_SQLLIBRARY_CFLAGS = -DSQLITE_ENABLE_PREUPDATE_HOOK
14+
CUSTOM_SQLLIBRARY_CFLAGS =

SQLiteLib.xcconfig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
//
22
// NOTE: DO NOT EDIT THIS FILE!
3-
// To specify additional custom SQLite compilation options, edit "SQLiteLib-Custom.xcconfig"
3+
// To specify additional custom SQLite compilation options, edit "SQLiteLib-USER.xcconfig"
44
//
55

6-
#include "SQLiteLib-Custom.xcconfig"
6+
CUSTOM_SQLLIBRARY_CFLAGS = // do not modify - use "SQLiteLib-USER.xcconfig"
7+
8+
#include "SQLiteLib-USER.xcconfig"
79

810
// SQLiteLib targets OS X 10.9
911
MACOSX_DEPLOYMENT_TARGET = 10.9
@@ -72,7 +74,7 @@ SUPPORTED_PLATFORMS = iphonesimulator macosx iphoneos appletvsimulator appletvos
7274
// ↑ UNCOMMENT THE LINES ABOVE to remove "gethostuuid() is disabled" warning on iOS/tvOS/watchOS.
7375

7476
// The common set of compilation options (on OSX and iOS).
75-
// NOTE: To add more compilation options, see SQLiteLibCustom.xcconfig.
77+
// NOTE: To add more compilation options, see SQLiteLib-USER.xcconfig.
7678
SQLLIBRARY_BASE_CFLAGS = -DSQLITE_ENABLE_API_ARMOR -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT -DSQLITE_OMIT_AUTORESET -DSQLITE_OMIT_BUILTIN_TEST -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_SYSTEM_MALLOC -DSQLITE_THREADSAFE=2 -DSQLITE_OS_UNIX=1 $(CUSTOM_SQLLIBRARY_CFLAGS)
7779

7880
SQLLIBRARY_OSX_ADDITIONAL_CFLAGS = -DSQLITE_ENABLE_LOCKING_STYLE=1

SQLiteLib.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
F32EB7781CFBC91D007C7948 /* sqlite3.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = sqlite3.h; sourceTree = "<group>"; };
4040
F32EB7D31CFBD08A007C7948 /* sqlite3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sqlite3.c; sourceTree = BUILT_PRODUCTS_DIR; };
4141
F3F14A621CF9E59E00E8D86B /* SQLiteLib.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = SQLiteLib.xcconfig; sourceTree = "<group>"; };
42-
F3F14A6D1CF9E9DB00E8D86B /* SQLiteLib-Custom.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "SQLiteLib-Custom.xcconfig"; sourceTree = "<group>"; };
42+
F3F14A6D1CF9E9DB00E8D86B /* SQLiteLib-USER.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "SQLiteLib-USER.xcconfig"; sourceTree = "<group>"; };
4343
/* End PBXFileReference section */
4444

4545
/* Begin PBXFrameworksBuildPhase section */
@@ -56,7 +56,7 @@
5656
08FB7794FE84155DC02AAC07 /* sqlcipher */ = {
5757
isa = PBXGroup;
5858
children = (
59-
F3F14A6D1CF9E9DB00E8D86B /* SQLiteLib-Custom.xcconfig */,
59+
F3F14A6D1CF9E9DB00E8D86B /* SQLiteLib-USER.xcconfig */,
6060
F3F14A621CF9E59E00E8D86B /* SQLiteLib.xcconfig */,
6161
08FB7795FE84155DC02AAC07 /* Source */,
6262
C6A0FF2B0290797F04C91782 /* Documentation */,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
6+
<false/>
7+
</dict>
8+
</plist>

SQLiteLib.xcodeproj/xcshareddata/xcschemes/amalgamation.xcscheme

Lines changed: 0 additions & 80 deletions
This file was deleted.

SQLiteLib.xcodeproj/xcshareddata/xcschemes/sqlitelib.xcscheme

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
33
LastUpgradeVersion = "0730"
4-
version = "1.3">
4+
version = "1.7">
55
<BuildAction
66
parallelizeBuildables = "YES"
77
buildImplicitDependencies = "YES">
8+
<PreActions>
9+
<ExecutionAction
10+
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
11+
<ActionContent
12+
title = "Process USER configuration"
13+
scriptText = "#&#10;# Process USER Configuration Files&#10;#&#10;# The choice of which FILE to use is as follows:&#10;# 1. If FILE exists in the parent directory of ${SRCROOT}, it is copied to ${SRCROOT}/FILE and used, else&#10;# 2. If FILE exists in ${SRCROOT} it is used, else&#10;# 3. The example file (FILE.example) is copied to ${SRCROOT}/FILE and is used&#10;&#10;SCRIPT_INPUT_FILE_COUNT=1&#10;SCRIPT_INPUT_FILE_0=&quot;${SRCROOT}/SQLiteLib-USER.xcconfig.example&quot;&#10;&#10;copiedfiles=false&#10;for ((i=0; i &lt; SCRIPT_INPUT_FILE_COUNT ; i++))&#10;do&#10; INFILE=SCRIPT_INPUT_FILE_$&#10; EXAMPLEFILE=${!INFILE};&#10; OUTPUTFILE=${EXAMPLEFILE%.example}&#10;&#10; OUTPUTFILENAME=$(basename $OUTPUTFILE)&#10;&#10; # Search parent directory of ${SRCROOT} for &quot;$OUTPUTFILENAME&quot; file.&#10; # Overwrite existing output file if parent override exists.&#10;&#10; PARENTOVERRIDE=&quot;${SRCROOT}/../${OUTPUTFILENAME}&quot;&#10;&#10; if [ -f &quot;$PARENTOVERRIDE&quot; ]&#10; then&#10; # Use parent override&#10; echo &quot;Parent USER configuration override exists - copying&quot;&#10; cp $PARENTOVERRIDE $OUTPUTFILE&#10; touch $OUTPUTFILE&#10; copiedfiles=true&#10; else&#10; # Use .example file, if output file doesn&apos;t exist&#10; if [ ! -f &quot;$OUTPUTFILE&quot; ];&#10; then&#10; echo &quot;${INFILE}=${EXAMPLEFILE}&quot;&#10; if [ -f &quot;$EXAMPLEFILE&quot; ]&#10; then&#10; echo &quot;Expected USER configuration file doesn&apos;t exist&quot;&#10; echo &quot;Copying .example file&quot;&#10; cp $EXAMPLEFILE $OUTPUTFILE&#10; touch $OUTPUTFILE&#10; copiedfiles=true&#10; else&#10; echo &quot;Missing input .example file: ${EXAMPLEFILE}&quot;&#10; exit 1&#10; fi&#10; else&#10; echo &quot;USER Configuration file already exists: ${OUTPUTFILE}&quot;&#10; echo &quot;Using existing file.&quot;&#10; fi&#10; fi&#10;done&#10;&#10;if [ &quot;$copiedfiles&quot; = true ] ; then&#10; touch &quot;${SRCROOT}/SQLiteLib.xcconfig&quot;&#10; sleep .5&#10;fi&#10;"
14+
shellToInvoke = "/bin/sh">
15+
<EnvironmentBuildable>
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "D2AAC045055464E500DB518D"
19+
BuildableName = "libsqlitecustom.a"
20+
BlueprintName = "sqlitecustom"
21+
ReferencedContainer = "container:SQLiteLib.xcodeproj">
22+
</BuildableReference>
23+
</EnvironmentBuildable>
24+
</ActionContent>
25+
</ExecutionAction>
26+
</PreActions>
827
<BuildActionEntries>
928
<BuildActionEntry
1029
buildForTesting = "YES"

0 commit comments

Comments
 (0)