Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-24242] Pass extra header search paths to metabase parser #118

Merged
merged 3 commits into from
Mar 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 36 additions & 1 deletion iphone/plugin/hyperloop.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,39 @@ HyperloopiOSBuilder.prototype.generateSourceFiles = function generateSourceFiles
}.bind(this), callback);
}

var extraHeaderSearchPaths = [];
var extraFrameworkSearchPaths = [];
if (this.hasCocoaPods) {
var addSearchPathsFromCocoaPods = function (target, source) {
if (!source) {
return;
}

var cocoaPodsRoot = this.cocoaPodsBuildSettings.PODS_ROOT;
var paths = source.split(" ");
paths.forEach(function(path) {
if (path === '$(inherited)') {
return;
}

var searchPath = path.replace('${PODS_ROOT}', cocoaPodsRoot);
searchPath = searchPath.replace(/"/g, '');
target.push(searchPath);
});
}.bind(this);

addSearchPathsFromCocoaPods(extraHeaderSearchPaths, this.cocoaPodsBuildSettings.HEADER_SEARCH_PATHS);
addSearchPathsFromCocoaPods(extraFrameworkSearchPaths, this.cocoaPodsBuildSettings.FRAMEWORK_SEARCH_PATHS);
}
if (this.hyperloopConfig.ios.thirdparty) {
Object.keys(this.hyperloopConfig.ios.thirdparty).forEach(function(frameworkName) {
var thirdPartyFrameworkConfig = this.hyperloopConfig.ios.thirdparty[frameworkName];
var searchPath = path.resolve(this.builder.projectDir, thirdPartyFrameworkConfig.header);
extraHeaderSearchPaths.push(searchPath);
extraFrameworkSearchPaths.push(searchPath);
}.bind(this));
}

// generate the metabase from our includes
hm.metabase.generateMetabase(
this.hyperloopBuildDir,
Expand All @@ -529,7 +562,9 @@ HyperloopiOSBuilder.prototype.generateSourceFiles = function generateSourceFiles
Object.keys(this.includes),
false, // don't exclude system libraries
generateMetabaseCallback.bind(this),
this.builder.forceCleanBuild || this.forceMetabase
this.builder.forceCleanBuild || this.forceMetabase,
extraHeaderSearchPaths,
extraFrameworkSearchPaths
);
};

Expand Down
10 changes: 8 additions & 2 deletions metabase/ios/lib/metabase.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ function generateSystemFrameworks (sdkPath, iosMinVersion, callback) {
* @param {Boolean} excludeSystem if true, will exclude any system libraries in the generated output
* @param {Function} callback function to receive the result which will be (err, json, json_file, header_file)
* @param {Boolean} force if true, will not use cache
* @param {Array} extraHeaders Array of extra header search paths passed to the metabase parser
* @param {Array} extraFrameworks Array of extra framework search paths passed to the metabase parser
*/
function generateMetabase (buildDir, sdk, sdkPath, iosMinVersion, includes, excludeSystem, callback, force, extraHeaders) {
function generateMetabase (buildDir, sdk, sdkPath, iosMinVersion, includes, excludeSystem, callback, force, extraHeaders, extraFrameworks) {
var cacheToken = crypto.createHash('md5').update(sdkPath + iosMinVersion + excludeSystem + JSON.stringify(includes)).digest('hex');
var header = path.join(buildDir, 'metabase-' + iosMinVersion + '-' + sdk + '-' + cacheToken + '.h');
var outfile = path.join(buildDir, 'metabase-' + iosMinVersion + '-' + sdk + '-' + cacheToken + '.json');
Expand Down Expand Up @@ -216,10 +218,14 @@ function generateMetabase (buildDir, sdk, sdkPath, iosMinVersion, includes, excl
if (excludeSystem) {
args.push('-x');
}
if (extraHeaders) {
if (extraHeaders && extraHeaders.length > 0) {
args.push('-hsp');
args.push('"' + extraHeaders.join(',') + '"');
}
if (extraFrameworks && extraFrameworks.length > 0) {
args.push('-fsp');
args.push('"' + extraFrameworks.join(',') + '"');
}
util.logger.trace('running', binary, 'with', args.join(' '));
var ts = Date.now();
var child = spawn(binary, args);
Expand Down
18 changes: 16 additions & 2 deletions metabase/ios/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ int main(int argc, char* argv[]) {
auto iphone_sim_root = arguments["-sim-sdk-path"];
auto prettify = arguments.count("-pretty") > 0;
auto excludeSys = arguments.count("-x") > 0;
auto bitArch = arguments.count("-bit") ? arguments["-bit"] : "64";
auto bitArch = arguments.count("-bit") ? arguments["-bit"] : "64";
auto includes = hyperloop::tokenize(arguments["-hsp"], ",");
auto frameworks = hyperloop::tokenize(arguments["-fsp"], ",");

std::string min_ios_version_command("-mios-simulator-version-min=" + min_ios_version);

Expand All @@ -120,7 +121,7 @@ int main(int argc, char* argv[]) {
args.push_back("-fmessage-length=0");
args.push_back("-fdiagnostics-show-note-include-stack");
args.push_back("-fmacro-backtrace-limit=0");
args.push_back(std::string("-m" + bitArch).c_str());
args.push_back(std::string("-m" + bitArch).c_str());

if (includes.size() > 0) {
for (auto i = 0; i < includes.size(); i++) {
Expand All @@ -135,6 +136,19 @@ int main(int argc, char* argv[]) {
args.push_back(strdup(each.c_str()));
}
}
if (frameworks.size() > 0) {
for (auto i = 0; i < frameworks.size(); i++) {
auto each = frameworks[i];
if (each.at(0) == (int)'"') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give me an example of the frameworks array? We should try to avoid doing those string-compares - people can also use ' for the iOS includes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's copied from the include step above. It has nothing to do with the import statements but will be generated in https://github.com/appcelerator/hyperloop.next/pull/118/files#diff-ab30ce96af74b6522ec0cbb3a275fc14R227 and is a path. These lines will trim leading and trailing " from that path. For example "/Users/jvennemann/Development/appc/hyperloop-examples/src"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I were at the Framework includes, not the Framework search paths..

each = each.substr(1);
}
if (each.at(each.length() - 1) == (int)'"') {
each = each.substr(0, each.length() - 1);
}
args.push_back("-F");
args.push_back(strdup(each.c_str()));
}
}

args.push_back("-v");
args.push_back("-isysroot");
Expand Down