Skip to content

Commit 3cb69b0

Browse files
Merge pull request Marketcircle#6 from Marketcircle/ryder/apple-silicon-iphonesimulator
Support iphonesimulator on arm64
2 parents d600b8e + 62607c6 commit 3cb69b0

File tree

33 files changed

+5760
-106
lines changed

33 files changed

+5760
-106
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Externals
2+
DerivedData
23

34
example/ios/iOS UI Test/DerivedData
45
scripts/prebuilt.list

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "libetpan"]
2+
path = libetpan
3+
url = [email protected]:Marketcircle/libetpan

build-mac/mailcore2.xcodeproj/project.pbxproj

Lines changed: 46 additions & 86 deletions
Large diffs are not rendered by default.

build.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
3+
DERIVED_DATA_DIR="DerivedData"
4+
PRODUCTS_DIR="${DERIVED_DATA_DIR}/Build/Products"
5+
6+
# carthage adds these, not sure if necessary
7+
EXTRA_ARGS="ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="
8+
9+
# Embed bitcode for iphoneos binaries
10+
EXTRA_IPHONEOS_ARGS="ENABLE_BITCODE=YES BITCODE_GENERATION_MODE=bitcode"
11+
12+
# libetpan has been set up to build an xcframework for libsasl2, however xcframeworks must exist at the *start* of the build process
13+
# I didn't have time to figure out something less awful than building libetpan first
14+
# It'll copy sasl.xcframework to the build directory
15+
xcodebuild -project build-mac/mailcore2.xcodeproj -scheme "libetpan ios" -configuration Release -derivedDataPath ${DERIVED_DATA_DIR} -sdk iphoneos ${EXTRA_ARGS} ${EXTRA_IPHONEOS_ARGS}
16+
xcodebuild -project build-mac/mailcore2.xcodeproj -scheme "libetpan ios" -configuration Release -derivedDataPath ${DERIVED_DATA_DIR} -sdk iphonesimulator ${EXTRA_ARGS}
17+
18+
# mailcore2 references the sasl.xcframework in the build directory
19+
xcodebuild -project build-mac/mailcore2.xcodeproj -scheme "mailcore ios" -configuration Release -derivedDataPath ${DERIVED_DATA_DIR} -sdk iphoneos ${EXTRA_ARGS} ${EXTRA_IPHONEOS_ARGS}
20+
xcodebuild -project build-mac/mailcore2.xcodeproj -scheme "mailcore ios" -configuration Release -derivedDataPath ${DERIVED_DATA_DIR} -sdk iphonesimulator ${EXTRA_ARGS}
21+
22+
# glue it all together
23+
# note -debug-symbols path has to be absolute, see https://developer.apple.com/forums/thread/655768
24+
xcodebuild -create-xcframework \
25+
-framework "${PRODUCTS_DIR}/Release-iphoneos/MailCore.framework" \
26+
-debug-symbols "${PWD}/${PRODUCTS_DIR}/Release-iphoneos/MailCore.framework.dSYM" \
27+
-framework "${PRODUCTS_DIR}/Release-iphonesimulator/MailCore.framework" \
28+
-debug-symbols "${PWD}/${PRODUCTS_DIR}/Release-iphonesimulator/MailCore.framework.dSYM" \
29+
-output "${PRODUCTS_DIR}/MailCore.xcframework"
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright (c) 2012, Olaf van der Spek <[email protected]>
2+
// All rights reserved.
3+
//
4+
// Redistribution and use in source and binary forms, with or without
5+
// modification, are permitted provided that the following conditions are
6+
// met:
7+
//
8+
// * Redistributions of source code must retain the above copyright
9+
// notice, this list of conditions and the following disclaimer.
10+
// * Redistributions in binary form must reproduce the above
11+
// copyright notice, this list of conditions and the following disclaimer
12+
// in the documentation and/or other materials provided with the
13+
// distribution.
14+
// * Neither the name of Google Inc. nor the names of its
15+
// contributors may be used to endorse or promote products derived from
16+
// this software without specific prior written permission.
17+
//
18+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
30+
// ---
31+
// Author: Olaf van der Spek <[email protected]>
32+
33+
#ifndef TEMPLATE_FIND_PTR_H_
34+
#define TEMPLATE_FIND_PTR_H_
35+
36+
37+
38+
namespace ctemplate {
39+
40+
template <class T, class U>
41+
typename T::value_type::second_type* find_ptr(T& c, U v)
42+
{
43+
typename T::iterator i = c.find(v);
44+
return i == c.end() ? NULL : &i->second;
45+
}
46+
47+
template <class T, class U>
48+
const typename T::value_type::second_type* find_ptr(const T& c, U v)
49+
{
50+
typename T::const_iterator i = c.find(v);
51+
return i == c.end() ? NULL : &i->second;
52+
}
53+
54+
template <class T, class U>
55+
typename T::value_type::second_type find_ptr2(T& c, U v)
56+
{
57+
typename T::iterator i = c.find(v);
58+
return i == c.end() ? NULL : i->second;
59+
}
60+
61+
template <class T, class U>
62+
const typename T::value_type::second_type find_ptr2(const T& c, U v)
63+
{
64+
typename T::const_iterator i = c.find(v);
65+
return i == c.end() ? NULL : i->second;
66+
}
67+
68+
}
69+
70+
#endif // TEMPLATE_FIND_PTR_H_
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
// Copyright (c) 2008, Google Inc.
2+
// All rights reserved.
3+
//
4+
// Redistribution and use in source and binary forms, with or without
5+
// modification, are permitted provided that the following conditions are
6+
// met:
7+
//
8+
// * Redistributions of source code must retain the above copyright
9+
// notice, this list of conditions and the following disclaimer.
10+
// * Redistributions in binary form must reproduce the above
11+
// copyright notice, this list of conditions and the following disclaimer
12+
// in the documentation and/or other materials provided with the
13+
// distribution.
14+
// * Neither the name of Google Inc. nor the names of its
15+
// contributors may be used to endorse or promote products derived from
16+
// this software without specific prior written permission.
17+
//
18+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
30+
// ---
31+
// Author: [email protected] (Craig Silverstein)
32+
//
33+
// In addition to a TemplateDictionary, there is also a PerExpandData
34+
// dictionary. This dictionary holds information that applies to one
35+
// call to Expand, such as whether to annotate the template expansion
36+
// output. A template dictionary is associated with a template (.tpl)
37+
// file; a per-expand dictionary is associated to a particular call to
38+
// Expand() in a .cc file.
39+
//
40+
// For (many) more details, see the doc/ directory.
41+
42+
#ifndef TEMPLATE_PER_EXPAND_DATA_H_
43+
#define TEMPLATE_PER_EXPAND_DATA_H_
44+
45+
#include <stdlib.h> // for NULL
46+
#include <string.h> // for strcmp
47+
#include <sys/types.h>
48+
#include <map>
49+
#include <ctemplate/template_string.h> // for StringHash
50+
51+
52+
53+
namespace ctemplate {
54+
55+
class TemplateModifier;
56+
class TemplateAnnotator;
57+
58+
class PerExpandData {
59+
public:
60+
PerExpandData()
61+
: annotate_path_(NULL),
62+
annotator_(NULL),
63+
expand_modifier_(NULL),
64+
map_(NULL) { }
65+
66+
~PerExpandData();
67+
68+
// Indicate that annotations should be inserted during template expansion.
69+
// template_path_start - the start of a template path. When
70+
// printing the filename for template-includes, anything before and
71+
// including template_path_start is elided. This can make the
72+
// output less dependent on filesystem location for template files.
73+
void SetAnnotateOutput(const char* template_path_start) {
74+
annotate_path_ = template_path_start;
75+
}
76+
77+
// Whether to annotate the expanded output.
78+
bool annotate() const { return annotate_path_ != NULL; }
79+
80+
// The annotate-path; undefined if annotate() != true
81+
const char* annotate_path() const { return annotate_path_; }
82+
83+
// This sets the TemplateAnnotator to be used when annotating is on.
84+
// This allows you to override the default text-based annotator
85+
// that will be used if you do not call this. The passed annotator
86+
// will be aliased by this object and returned by annotator().
87+
// Passing NULL has the special behavior of causing annotator() to
88+
// revert to returning its built-in instance.
89+
void SetAnnotator(TemplateAnnotator* annotator) {
90+
annotator_ = annotator;
91+
}
92+
93+
// This returns the TemplateAnnotator to be used when annotating is on.
94+
// The value returned will be either an instance previously provided
95+
// to SetAnnotator() or the callable built-in text-based annotator.
96+
TemplateAnnotator* annotator() const;
97+
98+
// This is a TemplateModifier to be applied to all templates
99+
// expanded via this call to Expand(). That is, this modifier is
100+
// applies to the template (.tpl) file we expand, as well as
101+
// sub-templates that are expanded due to {{>INCLUDE}} directives.
102+
// Caller is responsible for ensuring that modifier exists for the
103+
// lifetime of this object.
104+
void SetTemplateExpansionModifier(const TemplateModifier* modifier) {
105+
expand_modifier_ = modifier;
106+
}
107+
108+
const TemplateModifier* template_expansion_modifier() const {
109+
return expand_modifier_;
110+
}
111+
112+
// Store data in this structure, to be used by template modifiers
113+
// (see template_modifiers.h). Call with value set to NULL to clear
114+
// any value previously set. Caller is responsible for ensuring key
115+
// and value point to valid data for the lifetime of this object.
116+
void InsertForModifiers(const char* key, const void* value);
117+
118+
// Retrieve data specific to this Expand call. Returns NULL if key
119+
// is not found. This should only be used by template modifiers.
120+
const void* LookupForModifiers(const char* key) const;
121+
122+
// Same as Lookup, but casts the result to a c string.
123+
const char* LookupForModifiersAsString(const char* key) const {
124+
return static_cast<const char*>(LookupForModifiers(key));
125+
}
126+
127+
private:
128+
#ifdef _MSC_VER
129+
typedef std::map<const char*, const void*, StringHash> DataMap;
130+
#else
131+
struct DataEq {
132+
bool operator()(const char* s1, const char* s2) const;
133+
};
134+
typedef std::map<const char*, const void*, StringHash>
135+
DataMap;
136+
#endif
137+
138+
const char* annotate_path_;
139+
TemplateAnnotator* annotator_;
140+
const TemplateModifier* expand_modifier_;
141+
DataMap* map_;
142+
143+
PerExpandData(const PerExpandData&); // disallow evil copy constructor
144+
void operator=(const PerExpandData&); // disallow evil operator=
145+
};
146+
147+
}
148+
149+
#endif // TEMPLATE_PER_EXPAND_DATA_H_
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
// Copyright (c) 2012, Olaf van der Spek <[email protected]>
2+
// All rights reserved.
3+
//
4+
// Redistribution and use in source and binary forms, with or without
5+
// modification, are permitted provided that the following conditions are
6+
// met:
7+
//
8+
// * Redistributions of source code must retain the above copyright
9+
// notice, this list of conditions and the following disclaimer.
10+
// * Redistributions in binary form must reproduce the above
11+
// copyright notice, this list of conditions and the following disclaimer
12+
// in the documentation and/or other materials provided with the
13+
// distribution.
14+
// * Neither the name of Google Inc. nor the names of its
15+
// contributors may be used to endorse or promote products derived from
16+
// this software without specific prior written permission.
17+
//
18+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
30+
// ---
31+
// Author: Olaf van der Spek <[email protected]>
32+
33+
#ifndef TEMPLATE_STR_REF_H_
34+
#define TEMPLATE_STR_REF_H_
35+
36+
#include <cstddef>
37+
38+
39+
40+
namespace ctemplate {
41+
42+
template <class T>
43+
class str_ref_basic
44+
{
45+
public:
46+
str_ref_basic()
47+
{
48+
clear();
49+
}
50+
51+
template <class U>
52+
str_ref_basic(const U& c)
53+
{
54+
if (c.end() != c.begin())
55+
assign(&*c.begin(), c.end() - c.begin() + &*c.begin());
56+
else
57+
clear();
58+
}
59+
60+
str_ref_basic(const void* b, const void* e)
61+
{
62+
assign(b, e);
63+
}
64+
65+
str_ref_basic(const void* b, size_t sz)
66+
{
67+
assign(b, sz);
68+
}
69+
70+
str_ref_basic(const char* b)
71+
{
72+
if (b)
73+
assign(b, strlen(b));
74+
else
75+
clear();
76+
}
77+
78+
void clear()
79+
{
80+
begin_ = end_ = NULL;
81+
}
82+
83+
void assign(const void* b, const void* e)
84+
{
85+
begin_ = reinterpret_cast<T>(b);
86+
end_ = reinterpret_cast<T>(e);
87+
}
88+
89+
void assign(const void* b, size_t sz)
90+
{
91+
begin_ = reinterpret_cast<T>(b);
92+
end_ = begin_ + sz;
93+
}
94+
95+
T begin() const
96+
{
97+
return begin_;
98+
}
99+
100+
T end() const
101+
{
102+
return end_;
103+
}
104+
105+
T data() const
106+
{
107+
return begin();
108+
}
109+
110+
size_t size() const
111+
{
112+
return end() - begin();
113+
}
114+
115+
bool empty() const
116+
{
117+
return begin() == end();
118+
}
119+
private:
120+
T begin_;
121+
T end_;
122+
};
123+
124+
typedef str_ref_basic<const unsigned char*> data_ref;
125+
typedef str_ref_basic<const char*> str_ref;
126+
127+
}
128+
129+
#endif // TEMPLATE_STR_REF_H_

0 commit comments

Comments
 (0)