@@ -68,9 +68,10 @@ json ComputeManifest(const PathMap &path_to_contents) {
6868}
6969
7070std::string GetDevserverLoaderScriptContents (
71- const std::string &workspace_root) {
72- const std::string devserver_loader_path =
73- std::string (kWorkspaceName ) + " /devserver/devserver_loader.js" ;
71+ const std::string &runfiles_root, const std::string &workspace_root) {
72+ const std::string devserver_loader_path = runfiles_root + " /" +
73+ std::string (kWorkspaceName ) +
74+ " /devserver/devserver_loader.js" ;
7475 DEBUG_LOG (" devserver_loader_path: " << devserver_loader_path);
7576
7677 std::string devserver_loader_contents;
@@ -136,8 +137,8 @@ PathMap ComputePathMap(const std::string &workspace_root,
136137
137138Arguments ParseArguments (int argc, char **argv) {
138139 std::string workspace_name = kWorkspaceName ;
139- args::ArgumentParser parser (" This is a test program. " ,
140- " This goes after the options ." );
140+ args::ArgumentParser parser (" rules_devserver " ,
141+ " Bazel web development server ." );
141142 args::ValueFlag<int32_t > port (parser, " port" , " Server port" , {" port" },
142143 kDefaultPort );
143144 args::ValueFlagList<std::string> static_files (
@@ -166,9 +167,7 @@ Arguments ParseArguments(int argc, char **argv) {
166167 DEBUG_LOG (" workspace_name: " << workspace_name);
167168 }
168169
169- const std::vector<std::string> static_files_list (args::get (static_files));
170-
171- return Arguments{args::get (port), static_files_list, workspace_name};
170+ return Arguments{args::get (port), args::get (static_files), workspace_name};
172171}
173172
174173int main (int argc, char **argv) {
@@ -183,7 +182,11 @@ int main(int argc, char **argv) {
183182 const std::vector<std::string> static_files = args.static_files ;
184183 const std::string workspace_name = args.workspace_name ;
185184
186- const std::string workspace_root = runfiles->Rlocation (workspace_name + " /" );
185+ std::string workspace_root = runfiles->Rlocation (workspace_name);
186+ const std::string runfiles_root =
187+ workspace_root.substr (0 , workspace_root.find_last_of (" /" ));
188+ workspace_root = workspace_root + " /" ;
189+ DEBUG_LOG (" runfiles_root: " << runfiles_root);
187190 DEBUG_LOG (" workspace_root: " << workspace_root << " \n\n " );
188191
189192 const PathMap path_map = ComputePathMap (workspace_root, static_files);
@@ -202,12 +205,13 @@ int main(int argc, char **argv) {
202205 res.set_content (contents, " text/html" );
203206 });
204207 }
205- svr.Get (
206- " /devserver/devserver_loader.js" ,
207- [&workspace_root](const httplib::Request &req, httplib::Response &res) {
208- res.set_content (GetDevserverLoaderScriptContents (workspace_root),
209- " text/javascript" );
210- });
208+ svr.Get (" /devserver/devserver_loader.js" ,
209+ [&runfiles_root, &workspace_root](const httplib::Request &req,
210+ httplib::Response &res) {
211+ res.set_content (
212+ GetDevserverLoaderScriptContents (runfiles_root, workspace_root),
213+ " text/javascript" );
214+ });
211215
212216 svr.Get (" /devserver/manifest" ,
213217 [&manifest](const httplib::Request &req, httplib::Response &res) {
0 commit comments