@@ -114,16 +114,20 @@ def install_bundler(runtime_ctx, bundler_version):
114114 )
115115
116116def bundle_install (runtime_ctx , previous_result ):
117+ cwd = runtime_ctx .ctx .path ("." )
118+ bundler_args = [
119+ "install" ,
120+ "--binstubs={}" .format (cwd .get_child (BUNDLE_BIN_PATH )),
121+ "--path={}" .format (cwd .get_child (BUNDLE_PATH )),
122+ "--standalone" ,
123+ "--gemfile={}" .format (runtime_ctx .ctx .attr .gemfile .name ),
124+ ]
125+ if runtime_ctx .ctx .attr .gemfile_lock :
126+ bundler_args += ["--deployment" , "--frozen" ]
127+
117128 result = run_bundler (
118129 runtime_ctx ,
119- [
120- "install" ,
121- "--binstubs={}" .format (BUNDLE_BIN_PATH ),
122- "--path={}" .format (BUNDLE_PATH ),
123- "--deployment" ,
124- "--standalone" ,
125- "--frozen" ,
126- ],
130+ bundler_args ,
127131 previous_result ,
128132 )
129133
@@ -133,6 +137,11 @@ def bundle_install(runtime_ctx, previous_result):
133137 return result
134138
135139def generate_bundle_build_file (runtime_ctx , previous_result ):
140+ if runtime_ctx .ctx .attr .gemfile_lock :
141+ gemfile_lock = runtime_ctx .ctx .attr .gemfile_lock .name
142+ else :
143+ gemfile_lock = "{}.lock" .format (runtime_ctx .ctx .attr .gemfile .name )
144+
136145 # Create the BUILD file to expose the gems to the WORKSPACE
137146 # USAGE: ./create_bundle_build_file.rb BUILD.bazel Gemfile.lock repo-name [excludes-json] workspace-name
138147 args = [
@@ -142,7 +151,7 @@ def generate_bundle_build_file(runtime_ctx, previous_result):
142151 "bundler/lib" ,
143152 SCRIPT_BUILD_FILE_GENERATOR , # The template used to created bundle file
144153 "BUILD.bazel" , # Bazel build file (can be empty)
145- "Gemfile.lock" , # Gemfile.lock where we list all direct and transitive dependencies
154+ gemfile_lock , # Gemfile.lock where we list all direct and transitive dependencies
146155 runtime_ctx .ctx .name , # Name of the target
147156 repr (runtime_ctx .ctx .attr .includes ),
148157 repr (runtime_ctx .ctx .attr .excludes ),
@@ -154,15 +163,18 @@ def generate_bundle_build_file(runtime_ctx, previous_result):
154163 fail ("build file generation failed: %s%s" % (result .stdout , result .stderr ))
155164
156165def _ruby_bundle_impl (ctx ):
157- ctx .symlink (ctx .attr .gemfile , "Gemfile" )
158- ctx .symlink (ctx .attr .gemfile_lock , "Gemfile.lock" )
166+ ctx .symlink (ctx .attr .gemfile , ctx .attr .gemfile .name )
167+ if ctx .attr .gemfile_lock :
168+ ctx .symlink (ctx .attr .gemfile_lock , ctx .attr .gemfile_lock .name )
159169 if ctx .attr .vendor_cache :
160170 ctx .symlink (
161171 ctx .path (str (ctx .path (ctx .attr .gemfile ).dirname ) + "/vendor" ),
162172 ctx .path ("vendor" ),
163173 )
164174 ctx .symlink (ctx .attr ._create_bundle_build_file , SCRIPT_BUILD_FILE_GENERATOR )
165175 ctx .symlink (ctx .attr ._install_bundler , SCRIPT_INSTALL_GEM )
176+ for src in ctx .attr .srcs :
177+ ctx .symlink (src , src .name )
166178
167179 bundler_version = ctx .attr .bundler_version
168180
0 commit comments