Merge lp:~webapps/unity-js-scopes/fix-npm-build into lp:unity-js-scopes

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Marcus Tomlinson
Approved revision: 87
Merged at revision: 85
Proposed branch: lp:~webapps/unity-js-scopes/fix-npm-build
Merge into: lp:unity-js-scopes
Prerequisite: lp:~abreu-alexandre/unity-js-scopes/remove-factory-new-constructs
Diff against target: 79 lines (+41/-7)
1 file modified
src/tool/main.cc (+41/-7)
To merge this branch: bzr merge lp:~webapps/unity-js-scopes/fix-npm-build
Reviewer Review Type Date Requested Status
Alexandre Abreu (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+274371@code.launchpad.net

Commit message

Detect current arch for unity-js-scopes-tool build.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
85. By Marcus Tomlinson

Merged remove-factory-new-constructs

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

A small comment

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
86. By Marcus Tomlinson

Added better error checking to get_arch() call

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

> A small comment

fixed

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
87. By Marcus Tomlinson

Merged trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/tool/main.cc'
2--- src/tool/main.cc 2015-10-06 20:01:49 +0000
3+++ src/tool/main.cc 2015-10-16 10:48:39 +0000
4@@ -30,6 +30,38 @@
5 #include <boost/algorithm/string/predicate.hpp>
6 #include <boost/filesystem.hpp>
7
8+std::string get_arch() {
9+ std::string result = "";
10+
11+ {
12+ FILE* pipe = popen("dpkg-architecture -qDEB_HOST_ARCH", "r");
13+ if (!pipe) throw std::runtime_error("'dpkg-architecture' command failed");
14+ char buffer[128];
15+ while (!feof(pipe)) {
16+ if (fgets(buffer, 128, pipe) != NULL)
17+ result += buffer;
18+ }
19+ result.pop_back();
20+ pclose(pipe);
21+ }
22+
23+ result += "-";
24+
25+ {
26+ FILE* pipe = popen("lsb_release -rs", "r");
27+ if (!pipe) throw std::runtime_error("'lsb_release' command failed");
28+ char buffer[128];
29+ while (!feof(pipe)) {
30+ if (fgets(buffer, 128, pipe) != NULL)
31+ result += buffer;
32+ }
33+ result.pop_back();
34+ pclose(pipe);
35+ }
36+
37+ return result;
38+}
39+
40 void usage() {
41 std::cout << "Usage:"
42 << std::endl
43@@ -41,7 +73,6 @@
44 << executable_name()
45 << " [re]build "
46 << "<path/to/node_modules> "
47- << "[<target_arch>]"
48 << std::endl;
49 }
50
51@@ -198,10 +229,13 @@
52 {
53 bool should_build = true;
54 std::string current_arch = "default";
55-
56- if (argc > 3)
57- {
58- current_arch = std::string(argv[3]);
59+ try
60+ {
61+ current_arch = get_arch();
62+ }
63+ catch (std::exception const& e)
64+ {
65+ std::cout << "Failed to detect target architecture (using 'default' instead): " << e.what() << " ..." << std::endl;
66 }
67
68 // Check if we have built for this arch already, if so set should_build to false
69@@ -221,8 +255,8 @@
70 {
71 std::vector<std::string> environment_updates;
72
73- std::cout << "Setting target arch to '" << current_arch << "' ..." << std::endl;
74- if (current_arch == "armhf")
75+ std::cout << "Setting target architecture to '" << current_arch << "' ..." << std::endl;
76+ if (boost::algorithm::starts_with(current_arch, "armhf"))
77 {
78 if (boost::filesystem::exists("/usr/bin/arm-linux-gnueabihf-gcc-5"))
79 {

Subscribers

People subscribed via source and target branches

to all changes: